Answers for "create api using fetch"

1

fetch api template

//fetch api template
const fetchData=(inputs)=>{
fetch('https://example.com/api', {
    method: 'post',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify(inputs)
  })
  .then(function(response) {
    return response.json();
  })
  .then(function(data) {
    ChromeSamples.log(data.whatever);
  });
}
Posted by: Guest on August-25-2020
4

fetch suntax

fetch('http://example.com/movies.json')
  .then((response) => {
    return response.json();
  })
  .then((data) => {
    console.log(data);
  });
Posted by: Guest on March-16-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language