首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >你能用一篇文章来获取数据吗?

你能用一篇文章来获取数据吗?
EN

Stack Overflow用户
提问于 2022-02-11 20:48:42
回答 2查看 97关注 0票数 0

一家公司要求我做一项Angular任务。它们提供了以下说明,但API URL不起作用:

代码语言:javascript
运行
复制
Create a single page angular application and use the following API to retrieve sports results and sort into a table of results that are displayed. Each sport result contains several data and always includes the publication time. 
Method: POST
Content-Type: application/json
Url: https://ancient-wood-1161.getsandbox.com:443/results 
Tasks:
-Display the sports results in reverse chronological order on the page.
-Add a filter to the page to display only certain types or events (e.g. f1Results)
-How can you confirm the code works?
-Bonus: Implement the rest call asynchronously

您现在可以单击URL,并看到它不工作-它返回https://ancient-wood-1161.getsandbox.com:443/results,在角度上它给我一个标准的CORS错误。

我要求公司发送一个工作URL和/或更新API以接受来自任何地方的请求。他们的反应是:*guy's name* confirmed it worked. It is a post and the content type is json.

您能使用POST请求来处理GET数据吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2022-02-11 21:19:07

绝对一点儿没错。例如,您的avg请求返回一个访问令牌。它将是一个POST,因为POST也比获得更多的安全性,因为有效负载在正文中而不是URL字符串中。

至于他们的借口不起作用,试试邮递员,看看是否还会发生同样的问题。如果它仍然问他们,他们在哪里测试他们的API,就好像它在prem上一样,那么CORS就不会工作了。它很可能不是一家你想为之工作的公司。

票数 3
EN

Stack Overflow用户

发布于 2022-02-11 20:50:27

可以,停那儿吧。在某些情况下,这可能是必要的,因为GET不需要身体,而POST需要。这样你就可以绕过URL长度限制之类的问题了。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71086361

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档