Skip to content

Instantly share code, notes, and snippets.

@danieltorscho
Last active October 1, 2022 04:55
Show Gist options
  • Select an option

  • Save danieltorscho/082c3e872c290be1543fa271a9ccd106 to your computer and use it in GitHub Desktop.

Select an option

Save danieltorscho/082c3e872c290be1543fa271a9ccd106 to your computer and use it in GitHub Desktop.

Revisions

  1. danieltorscho revised this gist Oct 1, 2022. 1 changed file with 2 additions and 8 deletions.
    10 changes: 2 additions & 8 deletions foreach map loop promise
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,5 @@
    myArray = await Promise.all(
    currencies.map(async item => {
    let usdt = item.total
    if (item.currency !== 'USDT') {
    const request = await axios.get(`https://api.binance.com/api/v3/ticker/price?symbol=${item.currency}USDT`)
    usdt = request.data.price * item.total
    }

    return { ...item, usdt }
    myArray.map(async item => {
    return await axios.get('https://url)
    })
    )
  2. danieltorscho created this gist Oct 1, 2022.
    11 changes: 11 additions & 0 deletions foreach map loop promise
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    myArray = await Promise.all(
    currencies.map(async item => {
    let usdt = item.total
    if (item.currency !== 'USDT') {
    const request = await axios.get(`https://api.binance.com/api/v3/ticker/price?symbol=${item.currency}USDT`)
    usdt = request.data.price * item.total
    }

    return { ...item, usdt }
    })
    )