[英]How can I code the result of this api request in visual studio
I am working on a Covid-19 Tracker Project which requires me to get and use api data through the URL https://thevirustracker.com/free-api?global=stats recommended on the website https://thevirustracker.com/api but for some reason I can neither access the suggested website nor can I get the required data through the suggested URL. I am working on a Covid-19 Tracker Project which requires me to get and use api data through the URL https://thevirustracker.com/free-api?global=stats recommended on the website https://thevirustracker.com/api但由于某种原因,我既无法访问建议的网站,也无法通过建议的 URL 获得所需的数据。
Instead I'm trying to do it through https://corona.lmao.ninja/v2/all?yesterday but the result has a slightly different structure and therefore I'm finding it hard to code in line 48 of my GlobalData.js file on Visual Studio in order to display the "cases" figure of the result of the api GET request under the "Global Data as of Today" in the first Paper section of the app.相反,我试图通过https://corona.lmao.ninja/v2/all?yesterday来实现,但结果的结构略有不同,因此我发现很难在 GlobalData.js 的第 48 行编码Visual Studio 上的文件,以便在应用程序的第一个论文部分的“截至今日的全球数据”下显示 api GET 请求结果的“案例”图。 Can someone please help me out?有人可以帮我吗?
Fetch api sends always you a promise so in console you can see that is a promise.获取 api 总是向您发送 promise 所以在控制台中您可以看到这是一个 promise。
try this you will get your actual data in console.试试这个,你会在控制台中得到你的实际数据。
fetch('https://corona.lmao.ninja/v2/all?yesterday').then((res)=>res.json()).then((data)=>console.log(data)).catch((err)=>console.log(err))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.