how can I set up value from axios.get method outside? I use TypeScript and I have not found any solution that works.
import axios, { AxiosInstance } from 'axios';
async function data() {
return await axios.get('https://myUrl/api/v4/3131', {
headers: {
'content-type': 'application/json',
'Authorization': 'Basic auth'
}
}).then(response => { return response.data})
.catch(error => {
console.log(error);
return Promise.reject(error);
});
}
var data = data();
console.log(response)