map an api response in vanilla javascript code example
Example: get response api using vanilajavascript
fetch('https://jsonplaceholder.typicode.com/postses').then(function (response) {
// The API call was successful!
if (response.ok) {
return response.json();
} else {
return Promise.reject(response);
}
}).then(function (data) {
// This is the JSON from our response
console.log(data);
}).catch(function (err) {
// There was an error
console.warn('Something went wrong.', err);
});