📜  获取 json - Javascript 代码示例

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

代码示例6
var myRequest = new Request('products.json');//GET
var myRequest = new Request('products.json', {method: "post"});//POST

fetch(myRequest)
  .then(response => response.json())
  .then(data => {
    console.log(data);
  })
  .catch(console.error);