windows.fetch code example
Example 1: javascript fetch api
fetch('http://example.com/movies.json')
.then((response) => {
return response.json();
})
.then((data) => {
console.log(data);
});
Example 2: .fetch method
fetch('http://example.com/movies.json')
.then(response => response.json())
.then(data => console.log(data));
Example 3: fetch api
const url = 'http://dummy.restapiexample.com/api/v1/create'
const user = {
name: 'Rahul'
age: '16'
salary: '000'
};
const options = {
method: 'POST'
body: JSON.stringify(user),
}
fetch(url, options)
.then( res => res.json())
.then( res=> console.log(res));