I am baffled by one particular problem. I am trying to set a cookie using the fetch api but I am unable to do so.
static deleteorder = (domain = "http://localhost:8080/pc", order) => {
let cooks = "JSESSIONID=AFAFWEEVV2323GG";
fetch(deleteorder, {
method: `GET`,
credentials: 'same-origin',
headers: {
"Content-type": `application/x-www-form-urlencoded`,
},
})
.then(res => {
console.log(res.status);
})
.catch(error => {
console.log(error);
});
};
}
When The function runs and 200
is returned but the data remains the same meaning the order remains. Can one of you shed some light? I am in the beginner phase of learning the fetch api so any feedback would be greatly appreciated.
Fetch()
simply sends the current document's cookies, so just add the cookie to document.cookie
.
static deleteorder = (domain = "http://localhost:8080/pc", order) => {
document.cookie = "JSESSIONID=AFAFWEEVV2323GG";
fetch(deleteorder, {
method: `GET`,
credentials: 'same-origin',
})
.then(res => {
console.log(res.status);
})
.catch(error => {
console.log(error);
});
};
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加