Q:

Is there a way for filer API endpoint JSON response?

I have an external API endpoint that uses basic authentication that I'm trying to find a specific key and/or value of from the JSON response. 
Results:
hrefsOnly returns an array with two items. 
[
"https://192.168.254.133/api/json/v2/types/volumes/1",
"https://192.168.254.133/api/json/v2/types/volumes/3"
]

Calling hrefsOnly[1] shows the following JSON response: 
{ "content": {
    "ancestor-vol-name": null,
    "small-io-alerts": "disabled",
    "last-refreshed-from-obj-name": null,
    "small-iops": "0",
    "wr-latency": "1738",
    "obj-severity": "information"
}}

volumeInfo is undefined in my code is below: 
const express = require('express');
const app = express();
const request = require("request");
const bodyParser = require('body-parser');

const auth = 'YWRtaW46WHRyZW0xMA==';

//Get Volume api endpoint values
var getVols = { 
  method: 'GET',
  url: 'https://192.168.254.133/api/json/v2/types/volumes/',
  headers: 
  { 
    'cache-control': 'no-cache',
    Accept: 'application/json',
    'Content-Type': 'application/json',
    Authorization: `Basic ${auth}` 
  } 
};

//Get above api endpoint data
var volsData = {
  method: 'GET',
  url: 'https://192.168.254.133/api/json/v2/types/volumes/1',
  headers: 
  { 
    'cache-control': 'no-cache',
    Accept: 'application/json',
    'Content-Type': 'application/json',
    Authorization: `Basic ${auth}` 
  } 
};

var hrefsOnly = [];
var volumeInfo = [];

//GET request to parse hfref data only
request(getVols, function (error, response, body) {
    var data = JSON.parse(body);
    if (error){
      console.log('error: ', error);
    } else {
      for(var i = 0; i < data["volumes"].length; i++){
        hrefsOnly.push(data["volumes"][i].href);
      }
    }
});

app.get('/url', (req, res, next) => {
    res.send(hrefsOnly);
});

// GET Volumes JSON response
request(volsData, function (error, response, body) {
    var vols = body;
    if (error){
      console.log('error: ', error);
    } else {
      for(var elem in vols){
        volumeInfo.push(vols);
      }
    }
});

app.get('/volume', (req, res, next) => {
  console.log(volumeInfo["content"]);
  res.send(volumeInfo["content"]);
});

process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
app.listen(3000, () => {
    console.log("Server running on port 3000");
});

I expect when I visit the page localhost:3000/volume to return the content section from the API. the page shows blank though. 
console.log(volumeInfo[1]) shows the JSON data, but volumeInfo[1].content is undefined. Not sure what I'm doing to get 'undefined' as the result.

A:

You declared an array var volumeInfo = []; but you're using it as a map res.send(volumeInfo["content"]);
TTo access an element inside an array, you need an index (integer). Try with res.send(volumeInfo[0].content);

