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));
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/12860495.html
未经授权禁止转载,违者必究!