I have a data array containing numbers and 1 object with a blob field. I walk through this array and in case the element is not a numeric value, I need to make a request and substitute a request instead of this object query result (id) How can I implement this functionality?
let data = {
photo: [33,24, {blob: 'blob'}, 44]
}
let newData = data.photos.map ((photo, i) => {
if (! isNaN (photo)) {
return photo
} else {
//?
let response = await fetch ('https://jsonplaceholder.typicode.com/todos/1');
let commits = await response.json ();
return commits.id
}
})
console.log (newPtotoObj)
Expected result => [33,24, value_from_request, 44]