javascript - fetch cannot customize header
滿天的星座
滿天的星座 2017-05-19 10:47:35
0
1
809
fetch(url, {
    method,
    mode: 'cors',
    headers: {
        "Test": "2222"
    }
})
.then(response => response.json())

Interface 404

滿天的星座
滿天的星座

reply all(1)
淡淡烟草味
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);
 });

It seems that the headers object is sent, and it seems that your method does not have a value. The 404 is because your url does not exist. Test it with postman first.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template