I want to call the API and use the API result for further computation But not able to do like this. Even after using async/await. I am getting the console value as undefined.I tried using promise as well but I am not getting how do I give authorization attribute to it. I am naive to js, can anyone help where I am going wrong?
var plan;
async function makeRequest() {
const config = {
"url": "https://jsonplaceholder.typicode.com/posts/1",
"method": "GET",
"timeout": 0,
"headers": {
"Authorization": "[Auth_url]"
},
};
let res = await axios(config)
console.log(res);
plan = res;
}
makeRequest();
console.log("plan",plan)
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>