1fetch('https://jsonplaceholder.typicode.com/postses').then(function (response) {
2 // The API call was successful!
3 if (response.ok) {
4 return response.json();
5 } else {
6 return Promise.reject(response);
7 }
8}).then(function (data) {
9 // This is the JSON from our response
10 console.log(data);
11}).catch(function (err) {
12 // There was an error
13 console.warn('Something went wrong.', err);
14});
15