Zara  Bryant

Zara Bryant

1549002597

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.

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)


#javascript #arrays #mongodb

What is GEEK

Buddha Community

Brooke Giles

1549013031

You can make use of Promise.all which will return the response from all the requests once all of them are successful

const PromiseArr = [];
for (let i = 0; i < info.length; i++){

var url = "https://whattomine.com/coins.json?" + algo + "=true" + "&factor%5B" + algo + "_hr%5D=" + info[i]
  PromiseArr.push(
   axios.get(url).then(result => new Promise(resolve => resolve(result.data.coins.Monero.btc_revenue)))
  );
}

Promise.all(PromiseArr).then(res => {
    console.log(res)
});

Zara  Bryant

Zara Bryant

1549002597

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.

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)


#javascript #arrays #mongodb

I am Developer

1597559012

Multiple File Upload in Laravel 7, 6

in this post, i will show you easy steps for multiple file upload in laravel 7, 6.

As well as how to validate file type, size before uploading to database in laravel.

Laravel 7/6 Multiple File Upload

You can easily upload multiple file with validation in laravel application using the following steps:

  1. Download Laravel Fresh New Setup
  2. Setup Database Credentials
  3. Generate Migration & Model For File
  4. Make Route For File uploading
  5. Create File Controller & Methods
  6. Create Multiple File Blade View
  7. Run Development Server

https://www.tutsmake.com/laravel-6-multiple-file-upload-with-validation-example/

#laravel multiple file upload validation #multiple file upload in laravel 7 #multiple file upload in laravel 6 #upload multiple files laravel 7 #upload multiple files in laravel 6 #upload multiple files php laravel

Joseph  Murray

Joseph Murray

1623911281

How to Print an Array in Java

Introduction

Printing an array is a quick way to give us visibility on the values of the contents inside. Sometimes the array values are the desired output of the program.

In this article, we’ll take a look at how to print an array in Java using four different ways.

While the “best way” depends on what your program needs to do, we begin with the simplest method for printing and then show more verbose ways to do it.

#java #array #how to print an array in java #array in java #print an array in java #print

How to Get Current URL in Laravel

In this small post we will see how to get current url in laravel, if you want to get current page url in laravel then we can use many method such type current(), full(), request(), url().

Here i will give you all example to get current page url in laravel, in this example i have used helper and function as well as so let’s start example of how to get current url id in laravel.

Read More : How to Get Current URL in Laravel

https://websolutionstuff.com/post/how-to-get-current-url-in-laravel


Read More : Laravel Signature Pad Example

https://websolutionstuff.com/post/laravel-signature-pad-example

#how to get current url in laravel #laravel get current url #get current page url in laravel #find current url in laravel #get full url in laravel #how to get current url id in laravel

I am Developer

1597470037

Laravel 7 Multiple Image Upload with Preview

Here, i will show you how to upload multiple image with preview using ajax in laravel.

Laravel 7 Ajax Multiple Image Upload with Preview

Just follow the below steps and upload multiple images using ajax with showing preview in laravel applications:

  • Install Laravel Fresh Setup
  • Setup Database Credentials
  • Create Route
  • Generate Controller By Command
  • Create the blade view
  • Start Development Server

https://www.tutsmake.com/laravel-7-6-ajax-multiple-image-upload-with-preview-e-g/

#laravel multiple image upload with preview #laravel multiple image validation #display multiple images in laravel #laravel multiple file upload #multiple image upload in laravel 6 #ajax image upload and preview with laravel