[英]API data is returning an error
I am using superagent to return the api data to the console, but I am greeted with these 2 errors 我正在使用超级代理将api数据返回到控制台,但是遇到了这2个错误
This is the code I am using: 这是我正在使用的代码:
componentDidMount () {
console.log("Did mount");
const url = 'https://api.goodzer.com/products/v0.1/search_stores/?query=v-neck+sweater&lat=40.7575285&lng=-73.9884469&radius=5&priceRange=30:120&apiKey=0816b72b7c798c6c6994c915b0a1854d';
superagent
.get(url)
.query(null)
.set('Accept', 'text/json')
.end((error, response) => {
console.log(JSON.stringify(response.body));
})
}
Why am I getting these errors? 为什么会出现这些错误?
I see 2 ways you can handle this: 我看到两种方法可以解决此问题:
1. Use the server 1.使用服务器
Make the api.goodzer.com
request on the server then feed the browser the results. 在服务器上
api.goodzer.com
请求,然后向浏览器提供结果。 I think this is probably the best solution but if you don't have access to the server you can use option 2. 我认为这可能是最好的解决方案,但是如果您无权访问服务器,则可以使用选项2。
2. Use the an Iframe 2.使用iframe
to make the api.goodzer.com
request. 发出
api.goodzer.com
请求。 This way the request happens in its own space. 这样,请求就在自己的空间中发生。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.