Saturday, 18 April 2020

callback in api

so i am trying to get a return back on my api call i keep getting getJob undefinedaxiosCalls [axiosCall = function(){    axiosCall.getJob = function(callback){      axios.get('someapi',{              headers:{                'Content-Type': 'application/json; charset=utf-8',                'x-authentication': 'api'              }// header        }).then(function(response) {            var datap = response           console.log(datap);            console.log("sucess");        return   callback(null,response.data)        }).catch(error => {            console.log("sucess");            console.log(error)         return    callback(null,"error");            }) // end of axios    }//end of function}// end of axiosCallmodule.exports = axiosCallRouter.js]   app.get('/api/test',function(req,res){       console.log("executing")        axiosCalls.getJob(async function(error,result){            if(error){              return  res.status(400).send(error.toString)            }// end of if            res.send(result)        })// adpafmkfmfnkbdfnknksnfjkn    });// end of api}// end of app routermodule.exports = appRouter;

Submitted April 18, 2020 at 08:34PM by codinginsomnia

No comments:

Post a Comment