I'm trying to create a module in node to return a json from API using axios request. But when i try to return the response out of the function getJson()
, nothing is returned to me.
const axios = require('axios');
const authentication = require('./authentication');
const url = `https://api.codenation.dev/v1/challenge/dev-ps/generate-data?token=${authentication.token}`;
const getJson = async () => {
const response = await axios.get(url);
// Here i can see the json normally
console.log(response.data)
return response.data
}
const response = getJson()
// but here nothing is shows to me in console.
console.log(response)