json
  • api
  • reactjs
  • superagent
  • 2017-01-08 67 views 0 likes 
    0

    我将SuperAgent到API的数据返回到控制台,但我用这2个错误enter image description hereAPI的数据返回错误

    迎接这是我使用的代码:

    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)); 
         }) 
         } 
    

    为什么我会收到这些错误?

    回答

    0

    我看到2种方法可以处理这个问题:

    1.使用服务器

    使服务器上的api.goodzer.com要求再喂浏览器的结果。我想,这可能是最好的解决方案,但如果你没有访问服务器,您可以使用选项2.

    2.使用的iframe

    使api.goodzer.com请求。这样的请求发生在自己的空间。

    相关问题