xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

egg.js 如何禁用 sensors data

egg.js 如何禁用 sensors data

holy shit 💩

http://localhost:7001/product/create

const json = {"id":"123","name":"admin"}

const url = `http://localhost:7001/product/create`;
const json = { id: '123', name: 'admin' };

const csrftoken = document.cookie.split(';').map(item => item.trim()).map(item => ({[item.split(`=`)[0]]: item.split(`=`)[1]})).filter(obj => obj.csrfToken)[0].csrfToken;;


fetch(url, {
  headers: {
    "Content-Type": "application/json",
    "x-csrf-token": csrftoken,
  },
  credentials: "include",// cookie
  method: "POST",
  mode: "cors",
  body: JSON.stringify(json),
})
.then(res => res.text())
// .then(res => res.json())
.then(json => {
  console.log(`text =`, json);
  // console.log(`json =`, JSON.stringify(json, null, 4));
  return json;
})
.catch(err => console.error(`error =`, err));


posted @ 2020-05-09 22:26  xgqfrms  阅读(217)  评论(2编辑  收藏  举报