0

This is my code:

    let data = []

    axios
            .get('https://api.spacexdata.com/v4/crew')
            .then(function(response) {
                // success
                data = response.data;
                console.log(data);
                return data
            })
            .catch(function(error) {
                // error
                console.log(error);
            })
        ;
    console.log(data);

I want to take all data from response.data and use it after that.

How do I do that?

Gheorghe
  • 25
  • 5
  • TLDR: `await` this Promise (returned by `axios.get()`) and then you can do whatever you want with it. The above question will provide lots of useful background. – Robin Zigmond Jun 20 '22 at 21:12
  • tho, can you make a comment with an example, please? i'm newbie here :D – Gheorghe Jun 21 '22 at 15:17

0 Answers0