简体   繁体   English

如何在 Visual Studio 中编码此 api 请求的结果

[英]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?有人可以帮我吗?

Pic Result of api GET request api GET 请求的图片结果

Pic GlobalData.js图片 GlobalData.js

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.

相关问题 如何在 Visual Studio 代码上修复智能感知? - How can i fix intelliSense on visual studio code? 如何在 Visual Studio Code 中运行这个 JavaScript 蛇游戏? - How can I run this JavaScript snake game in Visual Studio Code? 如何使用WebMatrix和Visual Studio调试代码? - How can I debug my code using WebMatrix and Visual Studio? 如何将api添加到Visual Studio代码 - How to add an api to Visual Studio Code 如何等待AJAX​​请求的结果? - How Can I Wait for the Result of an AJAX Request? 如何从Visual Studio Code API打开浏览器 - How to open browser from Visual Studio Code API 我如何使用Visual Studio 2008调试Coldfusion模板(coldfusion页面)中的javascript代码 - how can i debug javascript code within a coldfusion template(a coldfusion page) using visual studio 2008 如何在 Visual Studio Code 中因缺少导入而突出显示错误? - How can I get error highlighting for missing imports in Visual Studio Code? 如何从Visual Studio Code运行我的电子项目 - How can I run my electron project from Visual Studio Code Visual Studio Code,调试节点 - 我怎样才能达到这个“未验证的断点”? - Visual Studio Code, Debugging Node - How can I hit this 'Unverified Breakpoint'?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM