Semi-colons are placed only inside code blocks and at end of the last promise in the chain.
.then and .catch are similiar to UNIX file pipes process.
Response object methods
- .text
- .json
- .blob
fetch ('/examples//example.json')
.then(function(response){
return response.json();
}) // do something with the database
.catch (function(error){
console.log('Fetch error', error);
});fetch ('/examples/example.json')
.then(response => {
return response.json();
}) // do something with the database
.catch (error => {
console.log('Fetch error', error);
});fetch ('/examples/example.json')
.then(response => {
return response.json();
})
.then(json => {
console.log(json);
})
.catch (error => {
console.log('Fetch error', error);
});