Answers for "how to request by fetch js"

4

fetch api tutorial

fetch('https://api.github.com/users/manishmshiva', {
  method: "GET",
  headers: {"Content-type": "application/json;charset=UTF-8"}
})
.then(response => response.json()) 
.then(json => console.log(json)); 
.catch(err => console.log(err));
Posted by: Guest on October-20-2020
1

how to create a fetch function

const url = 'http://api.open-notify.org/astros.json'

const fetchurl = (url:string):void=>{

       fetch(url).then(res=>res.json()).then(jsonRes=>{
             
            console.log(jsonRes)
       })
}

fetchurl(url)
Posted by: Guest on April-28-2021
4

javascript fetch api

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