📜  fecth post json - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:25.494000             🧑  作者: Mango

代码示例2
var myHeaders = new Headers();

var myInit = { method: 'POST',
               headers: myHeaders,
               mode: 'cors',
               cache: 'default' };

fetch('flowers.jpg',myInit)
.then(function(response) {
  return response.blob();
})
.then(function(myBlob) {
  var objectURL = URL.createObjectURL(myBlob);
  myImage.src = objectURL;
});