Shoaib Iqbal
Shoaib Iqbal

Reputation: 2730

Extract Data from JSON object in angular 2

I have this reponse as JSON object.

Object {auth_token: "60a483bc0b1bc4dc0231ff0b90a67be1dad6ef45"} auth_token:"60a483bc0b1bc4dc0231ff0b90a67be1dad6ef45" proto : Object

I want to extract "60a483bc0b1bc4dc0231ff0b90a67be1dad6ef45" from this object. How can I do that?

Upvotes: 0

Views: 706

Answers (1)

Stephen R. Smith
Stephen R. Smith

Reputation: 3400

If you've assigned that response to a variable:

var someObject = {auth_token: "60a483bc0b1bc4dc0231ff0b90a67be1dad6ef45"};

You can extract the value by using object.key notation

var valueForKey_auth_token = this.someObject.auth_token;

console.log("valueForKey_auth_token", valueForKey_auth_token);

And you'll see this on the console

valueForKey_auth_token 60a483bc0b1bc4dc0231ff0b90a67be1dad6ef45

Upvotes: 1

Related Questions