fetch json file
fetch('http://example.com/movies.json')
.then((response) => {
return response.json();
})
.then((myJson) => {
console.log(myJson);
});const _fetch = async props => {
const { endpoint, options } = props
return await fetch(endpoint, options)
.then(async res => {
if (res.ok) {
return await res.clone().json().catch(() => res.text())
}
return false
})
.catch(err => {
console.error("api", "_fetch", "err", err)
return false
})
}fetch('http://example.com/movies.json')
.then((response) => {
return response.json();
})
.then((data) => {
console.log(data);
});
fetch('http://example.com/movies.json')
.then(response => response.json())
.then(data => console.log(data));
Also in JavaScript:
- link stylesheet in javascript
- radium is not working
- jest object containing
- Exception in thread "main" org.openqa.selenium.JavascriptException:
- javascript get index of object with value in array
- javascript send post data with ajax
- scoll a div to bottom in angular
- vue-js-toggle-button config
- angular http client
- lodash map
- get random numbers javascript
- js conditional object key
- log javascript
- javascript regex Zero or one occurrence
- javascript thread sleep
- react-native-screens
- client timezone offset in JavaScript
- christmas
- delete session javascript
- node js how to basic auth to specific urk
- angular get response headers
- javascript Count the occurrences of a value in an array
- javascript function return boolean
- copy link to clipboard