0

Here is my code so far:

var Qs = require('qs');

function runRequest() {
  return axios({
    method: 'GET',
    url: 'https://proxy.hackeryou.com',
    dataResponse: 'json',
    paramsSerializer: function (params) {
      return Qs.stringify(params, { arrayFormat: 'brackets' })
    },
    params: {
      reqUrl: `https://od-api.oxforddictionaries.com:443/api/v1/entries/en/bomb/synonyms;antonyms`,
      proxyHeaders: {
        'header_params': 'value',
        "Accept": "application/json",
        "app_id": "8ec64674",
        "app_key": "b5a5e3f12d46fc718b916e1aaa1c3509"
      },
      xmlToJSON: false
    }
  }).then((result) => {
       const synonym = result.data.results.map(res=>{
         return res.lexicalEntries.map(secondResult=>{
           return secondResult.entries.map(thirdResult=>{
               return thirdResult.senses.map(fourthRes=>{
                 return fourthRes.synonyms.map(fifthRes=>{
                  turnArray(fifthRes.id)
                  return fifthRes.id;
              })
            })
          })
        })
      });  
  })
    .catch((error) => {
      alert("Oops!");
    });
}

function turnArray(list){
  console.log(list)
}

runRequest();

What I am trying to do is turn this list (see image) into one array enter image description here

Example: ["explosive", "incendiary_device"];

I would like to do this in my turnArray() function. How can I go about doing that?

YVH
  • 187
  • 2
  • 3
  • 13
  • Possible duplicate of [Split string into array](https://stackoverflow.com/questions/7979727/split-string-into-array) – takendarkk Feb 16 '18 at 21:43
  • Possible duplicate of [Merge/flatten an array of arrays in JavaScript?](https://stackoverflow.com/questions/10865025/merge-flatten-an-array-of-arrays-in-javascript) – JDB Feb 16 '18 at 21:44

0 Answers0