I'm using Nest Js to call Axios to get data from Facebook API, but the service returns a null value. But when I call the response using console.log the value is returning. Am I missing something?
Here is my Controller File
@Get()
getCampaign(@Query() dto: ParamCampaignDto) {
this.adsService.readCampaign(dto)
}
And here is my service file
async readCampaign(dto: ParamCampaignDto) {
let response = null;
await axios.get(`https://graph.facebook.com/v14.0/act_${dto.accountId}/campaigns?access_token=${dto.accessToken}`)
.then(res => {
return res.data
console.log(res.data)
})
.catch(err => { return err })
console.log(response)
return response
}