Accessing values of an authorization request.

Hello - I've just made an OAuth request from discord and stored it in a requests object as follows:
export async function GET({ request, url }) {
console.log(request);
}
export async function GET({ request, url }) {
console.log(request);
}
The request object, when printed to the console, looks like this:
request Request {
[Symbol(realm)]: {
settingsObject: { baseUrl: undefined, origin: [Getter], policyContainer: [Object] }
},
etc...,
[Symbol(signal)]: AbortSignal { aborted: false },
[Symbol(headers)]: HeadersList {
cookies: null,
[Symbol(headers map)]: Map(15) {
'host' => [Object],
'connection' => [Object],
'sec-ch-ua' => [Object],
'sec-ch-ua-mobile' => [Object],
'sec-ch-ua-platform' => [Object],
'upgrade-insecure-requests' => [Object],
'user-agent' => [Object],
'accept' => [Object],
'sec-fetch-site' => [Object],
'sec-fetch-mode' => [Object],
'sec-fetch-user' => [Object],
'sec-fetch-dest' => [Object],
'accept-encoding' => [Object],
'accept-language' => [Object],
'cookie' => [Object]
},
[Symbol(headers map sorted)]: null
}
}
request Request {
[Symbol(realm)]: {
settingsObject: { baseUrl: undefined, origin: [Getter], policyContainer: [Object] }
},
etc...,
[Symbol(signal)]: AbortSignal { aborted: false },
[Symbol(headers)]: HeadersList {
cookies: null,
[Symbol(headers map)]: Map(15) {
'host' => [Object],
'connection' => [Object],
'sec-ch-ua' => [Object],
'sec-ch-ua-mobile' => [Object],
'sec-ch-ua-platform' => [Object],
'upgrade-insecure-requests' => [Object],
'user-agent' => [Object],
'accept' => [Object],
'sec-fetch-site' => [Object],
'sec-fetch-mode' => [Object],
'sec-fetch-user' => [Object],
'sec-fetch-dest' => [Object],
'accept-encoding' => [Object],
'accept-language' => [Object],
'cookie' => [Object]
},
[Symbol(headers map sorted)]: null
}
}
I need to access the object stored in the following path: request->[Symbol(headers)]->[Symbol(headers map)]->cookie. I managed to get console.log(request.headers) to print out the following, but I can't figure out how to get into the headers map object.
HeadersList {
cookies: null,
[Symbol(headers map)]: Map(15) {
'host' => "hostValue",
'connection' => "connectionValue",
etc.,
'cookie' => {
name: 'cookie',
value: 'someValueThatIHaveHidden'
}
},
[Symbol(headers map sorted)]: null
}
HeadersList {
cookies: null,
[Symbol(headers map)]: Map(15) {
'host' => "hostValue",
'connection' => "connectionValue",
etc.,
'cookie' => {
name: 'cookie',
value: 'someValueThatIHaveHidden'
}
},
[Symbol(headers map sorted)]: null
}
Any help would be much appreciated!
3 Replies
d.js toolkit
d.js toolkit8mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by staff
Tyranasaurus
Tyranasaurus8mo ago
I think the issue lies in what a 'Symbol' is but all I found was https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol Which didn't help me all that much
Symbol - JavaScript | MDN
Symbol is a built-in object whose constructor returns a symbol primitive — also called a Symbol value or just a Symbol — that's guaranteed to be unique. Symbols are often used to add unique property keys to an object that won't collide with keys any other code might add to the object, and which are hidden from any mechanisms other code will typi...
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View