I am trying a post request to http://localhost:5000/run. If the server is not running then trying to throw "Please retry again" to client.
try{
const {data} = await axios.post("http://localhost:5000/run",payload);
setOutput(data.output);
}
catch ({ response }) {
if (response) {
const errMsg = response.data.err.stderr;
setOutput(errMsg);
} else {
setOutput("Please retry submitting.");
}
}
when the server is running proper error is received but not when the server is offline. Anything missing from the code?
