0

I have the following code in express middleware...

const cert = req.cookies.Thing
console.log(` cookie is`, cert);
console.log("We got a cookie! "+ cert.property_a);

but the console shows...

 cookie is {"property_a":"blah","scope":"thing"}
 We got a cookie! undefined

If it is there, why can't I access the property? I even tried the JSON.parse(JSON.stringify) hack but no luck.

JGleason
  • 3,067
  • 6
  • 20
  • 54

2 Answers2

0

This may be helpful, if the issue is because of lazy resolving like promise.

Can't access object property, even though it exists. Returns undefined

Ramesh
  • 38
  • 5
0

Looks like the answer is although it displays like a JSON object it is a string. I solved this by using Object.values. This showed me a bunch of commas and I realized it wasn't getting parsed as JSON. Still trying to figure that last part out.

Object.values(cert)
JGleason
  • 3,067
  • 6
  • 20
  • 54