cesarzigma
4/14/2020 - 12:51 AM

Callback function after a vanilla JS fetch()

fetch('https://jsonplaceholder.typicode.com/posts').then(function (response) {
	if (response.ok) {
		return response.json();
	}
	return Promise.reject(response);
}).then(function (data) {
	console.log(data);
	render();
}).catch(function (error) {
	console.warn(error);
	render();
});