const headers = event.request.headers console.log('headers: ', headers) console.log('type is ', typeof headers) console.log('keys are ', Object.keys(headers)) console.log('cookie are ', headers.cookie)Producción:
headers: { accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9', 'accept-encoding': 'gzip, deflate, br', 'accept-language': 'en-GB,en-US;q=0.9,en;q=0.8', 'cache-control': 'max-age=0', connection: 'keep-alive', cookie: 'userid=7599271f-87de-4f44-8625-5d4dc4af4069; authToken=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImNsMWl4d2Y2aTAwMTdmNzNlcnVweWhqY3UiLCJpYXQiOjE2NDk1MTIzMjB9.ltrLZV7aFeNCmCtC5ZMVZvRhM5c285TAEWf_zFbVGs0', host: 'localhost:3000', 'if-none-match': '"1l79fw0"', referer: 'http://localhost:3000/profile', 'sec-fetch-dest': 'document', 'sec-fetch-mode': 'navigate', 'sec-fetch-site': 'same-origin', 'sec-gpc': '1', 'upgrade-insecure-requests': '1', 'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.45 Safari/537.36' } type is object keys are [] cookie are undefinedHaga clic aquí para ver la captura de pantalla de mi código
¿Alguien puede decir qué tiene de malo?
Debería ser event.request.headers.get(“cookie”)