S
S
Shane Matte2016-11-09 21:41:41
JavaScript
Shane Matte, 2016-11-09 21:41:41

How to take an array from a promise?

Hello. I can't figure out how promise works. I'm fetching an array from the server, but it's not possible to parse.
I change the state in react.

this.setState({
    info:api.getInfo().then(({data}) => data)
  })

In response, this is
57018ff563584bb296783512717b024b.png
How to get a simple array with data?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Belyaev, 2016-11-09
@mattedev

api.getInfo().then(({data}) => {
  this.setState({
    info: data
  });
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question