node.js – extract response form axis.request | node js

can you help me please, I need to extract some data from the axios requests response, but I don’t know how do it.

this is my code:

let result;

let config = {
    method: 'get',
    maxBodyLength: Infinity,
    url: urlToSend,
    headers: { 
        'Authorization': 'Bearer ' + token,
    }
};

axios.request(config)
    .then((response) => {
        //console.log(JSON.stringify(response.data));
        result = response.data;
    })
    .catch((error) => {
        console.log(error);
    });

console.log(result); //I NEED THE DATA HERE <-

The But the result is always: []

Thanks for your help,

Read more here: Source link