亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

fetch 無法自定義header

fetch 無法自定義header

HUX布斯 2018-11-14 13:15:43
fetch(url, {    method,    mode: 'cors',    headers: {        "Test": "2222"    }}).then(response => response.json())接口404
查看完整描述

1 回答

?
慕斯王

TA貢獻1864條經驗 獲得超2個贊

var headers = new Headers();

headers.append('Accept', 'application/json'); 

var request = new Request(URL, {

    headers: headers,

    method:"GET"

});

fetch(request).then(function(response) { 

    console.log(response);

 });

好像發送的是headers 對象,還有貌似你的method 也沒有給值,404是因為你的url 不存在的吧,先用postman 測試下。

查看完整回答
反對 回復 2018-12-06
  • 1 回答
  • 0 關注
  • 748 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號