I've been trying to do this in way too many ways. I haven't figured it out ChatGPT and Bard haven't figured it out so I though I would ask actual people 😁
I'm making an api call to usaspending.gov and am able to to get the information I want returned, but I can't figure out how to use the data I'm pulling down to create multiple records based on the objects returned. Has anyone run into this and how did you do it?
let uei = 'PLACE-UEI';
let startDate = '2023-10-01';
let endDate = '2023-12-31';
let data = {
"filters": {
"time_period": [
{
"start_date": startDate,
"end_date": endDate
}
],
"award_type_codes": [
"A",
"B",
"C",
"D"
],
"recipient_search_text": [
uei
]
},
"fields": [
"Award ID",
"Recipient Name",
"Start Date",
"End Date",
"Award Amount",
"Total Outlays",
"Description",
"def_codes",
"COVID-19 Obligations",
"COVID-19 Outlays",
"Infrastructure Obligations",
"Infrastructure Outlays",
"Awarding Agency",
"Awarding Sub Agency",
"Contract Award Type",
"recipient_id",
"prime_award_recipient_id"
],
"page": 1,
"limit": 60,
"sort": "Award Amount",
"order": "desc",
"subawards": false
};
let url = 'https://api.usaspending.gov/api/v2/search/spending_by_award/';
fetch(url, {
method: 'POST',
body: JSON.stringify(data),
headers: {
'Content-Type': 'application/json'
}
})
.then(response => response.json())
.then(data => {
console.log(data);
})
.catch(error => {
console.error(error);
});
Any help would be greatly appreciated.