axios-actions icon indicating copy to clipboard operation
axios-actions copied to clipboard

array.map requests causes error

Open aleksejssaburovs92 opened this issue 5 years ago • 2 comments

Using construction of

const data = await Promise.all(
  Object.values(this.orders).map(
    async (order) =>
      // await this.$axios.$get(`/authenticated/site/client/order/${order.id}`)
      await this.$api.auth.use('data').getClientTicketByOrderId({
        id: order.id
      })
  )
)

Causes error

TypeError: Cannot read property 'data' of null
    at eval (axios-actions.esm.js?2d04:491)
    at eval (axios-actions.esm.js?2d04:288)
    at Array.forEach (<anonymous>)
    at eval (axios-actions.esm.js?2d04:287)

Changing to normal axios request inside async function, works as expected

aleksejssaburovs92 avatar Jun 14 '20 21:06 aleksejssaburovs92

Hey, I'm finding it a bit hard to work on OS at the moment.

Is this a blocker for you?

davestewart avatar Jun 17 '20 11:06 davestewart

For now, i just changed

await this.$api.auth.use('data').getClientTicketByOrderId({
    id: order.id
})

to

await this.$axios.$get(`/authenticated/site/client/order/${order.id}`)

and it works ok, but it would be great if you could reproduce and fix it, because this approach causes me to move away endpoint from ApiGroup.

aleksejssaburovs92 avatar Jun 21 '20 16:06 aleksejssaburovs92