0
taskController.probeCin = async (req) => {
  let headers = {
    "x-api-key": "rCEyFavKJQ4V7***********",
    "x-api-version": 1.2
  }

  if (!req.body.cin || req.body.cin === "") {
    return ({
      statusCode: 400,
      message: "please enter valid cin number"
    })
  }

  cin = req.body.cin;
  url = await addUrl(cin, req.body.urlType)
  try {
    utilities.requestGet(url, headers, async (err, data) => {
      console.log("taskController.probeCin -> JSON.parse(data)", JSON.parse(data))
      return JSON.parse(data);
    })
  } catch (error) {
    throw error
    }
  }

when i hit below route it returns undefined and the console runs first before the code in the controller

 router.post('/probe-api/auditors', /*apiService,*/ async (req,res)=>{

        let response = await taskController.probeCin(req);
          console.log("response", response)
});

Response : response undefined

taskController.probeCin -> JSON.parse(data) { data ........ }

0 Answers0