the project uses a request made by fetch, and the background says that session can be used to handle session permissions! But how to add session in the request header.
after looking up the information, it is said that request.getSession can get it, but there is some doubt that request, can not be found in the request encapsulated by fetch. How to encapsulate it.
export const get = (url, query = {}, options = {}) => {
const defaultOpt = {
method: "GET",
timeout: requestTimeOut,
credentials: "include",
headers: { ...options }
}
defaultOpt.headers = completeHeader(defaultOpt.headers)
console.log(defaultOpt)
return fetch(getUrl(url, query), defaultOpt).then(checkStatus).then(parseJSON)
}
above is one of the examples
the Internet also says to join credentials: "include", but I still don"t quite understand.