json
  • api
  • reactjs
  • superagent
  • 2017-01-08 35 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請求。這樣的請求發生在自己的空間。

    相關問題