How do I wrap axios.get multiple response results into one array?

How do I wrap axios.get multiple response results into one array?

Hi I am trying to combine the results of my axios get request into one array.

Hi I am trying to combine the results of my axios get request into one array.

I am grabbing data from Mongoose and MongoDB database which returns me an array of relevant information for the axios request to run through

I run the info through axios.get and it returns me with respective results for each object in the array

See below

const axios = require("axios");

var info = [500000, 2020, 12341234, 12341234] var algo = "cn8"

console.log(info)

for (var i = 0; i < info.length; i++){

var url = "https://whattomine.com/coins.json?" + algo + "=true" + "&factor%5B" + algo + "_hr%5D=" + info[i]

axios.get(url) .then((response) => { var result = response.data.coins.Monero.btc_revenue

  console.log(result)
  })

}


However I am also trying to write this result back into my MongoDB/Mongoose database for further logging and someone suggested I can use the map function to run the write functions going back into the database for it.

However map only works for arrays and the results I am getting from axios are not. Does anyone have any idea how to join these response I am getting into one array?

I have attached a picture below for reference

Keep in mind these are the results for console.log(info) is in GREEN for data going in

console.log(result) is in RED for data supposed to be going out (need to transform into combined array first, not sure how to do when all the results are in one variable)


Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

How to Clone an Array in JavaScript?

In this JavaScript tutorial, you'll learn how to clone an array in JavaScript. Because arrays in JS are reference values, so when you try to copy it using the = it will only copy the reference to the original array and not the value of the array.

JavaScript Array.flatMap()

JavaScript Array.flatMap(): Use flatMap to map over an array and flatten the result array in one go! Now lets up the game and introduce "flatMap". It combines the steps of first mapping over the array with `map()` & then calling `flat()`. Instead of calling 2 methods, just use `flatMap()` 👍