do we have to require fetch code example
Example 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)
Example 2: work with fetches in js
function yourfunction() {
return fetch(API)
.then(response => response.json())
.then(data => data.content)
}