鍍金池/ 問(wèn)答/HTML/ axios請(qǐng)求報(bào)錯(cuò)405

axios請(qǐng)求報(bào)錯(cuò)405

我想用axios做一個(gè)請(qǐng)求,但是報(bào)錯(cuò)如下,No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8085' is therefore not allowed access. The response had HTTP status code 405.
然后我用jquery的方法請(qǐng)求了一次,沒(méi)有報(bào)錯(cuò),不明白axios請(qǐng)求為啥報(bào)錯(cuò),因?yàn)槭腔趘ue環(huán)境,所以也是第一次嘗試用axios請(qǐng)求,希望路過(guò)的各位大神指點(diǎn)一下

    axios({
      method: 'get',
      url: 'http://123.55.94.183:8091/apifit/transfer/transfer',
      responseType: 'json',
      data: PostJson({
                    fitUserId: 'belle',
                    reqTransfer: '/apifit/medal/getUser'
      })
    })
    .then(function (response) {
      console.log(response)
    })
    .catch(function (error) {
      console.log(error)
    })
回答
編輯回答
墻頭草

No 'Access-Control-Allow-Origin' header is present on the requested resource.

跨域請(qǐng)求錯(cuò)誤,要后端將響應(yīng)頭Access-Control-Allow-Origin設(shè)置成*就好了

2017年12月20日 20:57
編輯回答
萢萢糖

405是請(qǐng)求類(lèi)型錯(cuò)誤吧,你看看是不是后端不支持get方式的請(qǐng)求

2018年8月6日 12:14