I have a CURL request that will follow a standard request/response like the below.
Request
curl -X GET --header 'Accept: application/vnd.pager+json;version=2' --header 'Authorization: Token token=xxxxxxxxxxxxx' 'https://api.pager.com/users/12345?include%5B%5D=contact_methods
'
Response
{
"user": {
"name": "John Smith",
"email": "john@john.com",
"time_zone": "America/Los_Angeles",
"color": "indigo",
"avatar_url": "xxxx",
"billed": true,
"role": "user",
"description": null,
"invitation_sent": false,
"contact_methods": [
{
"id": "TP3D6TTZ",
"type": "email_contact_method",
"summary": "Default",
"self": "xxxxx",
"html_url": null,
"label": "Default",
"address": "xxxxx@xxxxxx.com",
"send_short_email": false,
"send_html_email": true
},
{
"id": "TPK4ZULL",
"type": "phone_contact_method",
"summary": "Work",
"self": "xxxxxxxxx",
"html_url": null,
"label": "Work",
"address": "5557304169",
"country_code": 1,
"blacklisted": false
}
],
}
What I want it to be able to strip some of the data out using Javascript and re-use them variables later on in my project.
So from the response I would like something like....
Var1 = John Smith Always the first 'name'
Var2 = email_contact_method Always the first 'type'
Var3 = xxxxx@xxxxxx.com Always the first 'address'
Var4 = phone_contact_method Always the second 'type'
Var5 = 5557304169 Always the second 'address'
I have tried somethings but I just don't know how to go about selecting only the fields that I want. Any pointers would be great....