Cors issue with third party api

泄露秘密 提交于 2020-01-04 05:31:17

问题


I am struggle with getting data from third party api on browser. 'https://www.coinexchange.io/api/v1/getmarkets'

I set mode:'no-cors' as option because it seems the response header does not include Access-Control-Allow-Origin. But mode: no-cors does not allow me to access to the data.

function callApi({ url }) {

  return fetch(url, {
    mode: 'no-cors'
  })
  .then(response => {
    if (!response) {
    }

    return response.json()
  })
  .then(response => {
    const camelizedJson = camelizeKeys(response)

    return Object.assign({},
      normalize(camelizedJson),
    )
  })

}

The response returns type: opaque like this image and response headers is this

I believe mode: no-cors works like sending GET request from HTML img tag so I can not use the information.

Is there any way to access to the third party API whose response header does not have Access-Control-Allow-Origin? How am I supposed to call third party public api?

If you have any ideas to fix this problem, please let me know! Thank you

来源:https://stackoverflow.com/questions/48123816/cors-issue-with-third-party-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!