0

I found this neat way of gathering multiple data from a web api via axios. However, the actual result of the axios call stays in the data property of the result. Is there an easy way to put the content of the data property into the deconstructed result, instead of the actual Axios object?

Here's my current code:

const [svcResp, allColumns] = await Promise.all([
    this.$http.get('Picking/ViewerSettings'),
    this.$http.get('Settings/SourceColumns')
]);

An untested idea would be something like this, but woud that work and would that be ideal?

const [svcResp, allColumns] = await Promise.all([
    (await this.$http.get('Picking/ViewerSettings')).data,
    (await this.$http.get('Settings/SourceColumns')).data
]);
André Reichelt
  • 1,484
  • 18
  • 52

1 Answers1

0

I found an answer that uses array as well as object deconstructors. I don't know, if this is an ideal solution, though:

const [{ data: svcResp }, { data: allColumns }] = await Promise.all([
    this.$http.get('Picking/ViewerSettings'),
    this.$http.get('Settings/SourceColumns')
]);
André Reichelt
  • 1,484
  • 18
  • 52