SELECT JSON NODEJS

Asked

Viewed 52 times

-1

So I have the following JSON :

var json = {
  'cache-control': 'no-store, must-revalidate, max-age=0',
  'content-length': '12747',
  'content-type': 'text/html;charset=utf-8',
  'content-language': 'pt-br',
  'set-cookie': [
    'ApplicationGatewayAffinity05CORS=97a3c470e904c1e72a708e84142b5859; Path=/; SameSite=None; Secure',
    'ApplicationGatewayAffinity05=97a3c470e904c1e72a708e84142b5859; Path=/']
}

How do I select the set-cookie? I tried var cookie = json.set-cookie but it doesn’t work.

  • 3

    json['set-cookie']

1 answer

0


Attributes of a Literal Object (JSON) can be accessed as keys in an array.

const cookie = json['set-cookie'];

Browser other questions tagged

You are not signed in. Login or sign up in order to post.