When I run my code, i get the message error.toJSON is not a function
. How am I supposed to handle this error better?
const installDependencies = async (BASE_URL, body) => {
try {
const headers = {
"Content-type": "application/json",
};
const response = await axios.post(`${BASE_URL}/data`, body, { headers });
return response;
} catch (error) {
console.error(error.response?.data, error.toJSON());
throw new Error("Failed to install dependencies");
}
};