So I moved over a non-reusable fetch request code snippet to my API:
let response = await fetch(visitURL, {
 method: 'POST',
 headers: {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer ' + userJWT
 },
 body: JSON.stringify(endingVisit)
});
if (response.ok) {
  let {visitId, createdAt} = await response.json();
  const viewVisitDto = new ViewVisitDto(`${visitId}${createdAt}${visitorId}${doctorId}${oldPatientId}`);
return viewVisitDto;
} else {
  throw new Error("deactivated!")
}
I was able to get this far:
axios.post(visitURL, {
  headers,
  body: JSON.stringify(visit)
}).then((response) => {
  console.log(response);
}).catch((error) => {
  console.log(error);
})
But does not exactly give me the visitId and createdAt from the response and I cannot use a response.ok nor a response.json(). Essentially I need to pull out that visitId and createdAt that should be coming back in the response.
I also tried just using node-fetch library, but although in VS code it seems to accept it, TypeScript is not happy with it even when I do install @types/node-fetch and even when I create a type definition file for it, my API just doesn't like it.
 
     
    