📜  如何创建 fetch 函数 - TypeScript 代码示例

📅  最后修改于: 2022-03-11 14:48:33.544000             🧑  作者: Mango

代码示例1
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)