I have the following code but I get no console output. It seems like no matter what I do it doesn't enter the then()
or catch()
.
axios
.post(url, {test: "0"})
.then(console.log)
.catch(console.error);
Interestingly enough the request gets posted and is received on the other end. I can also verify by mocking with postman that the endpoint is responding correctly. Where could this fail?
EDIT: It is getting even weirder: I tried the following and it instantly prints the promise:
console.log(await axios.post(url, {test: "0"}));
Unfortunately I am forced to use Node v8.11.1 - could this be the issue?
EDIT 2: .then(console.log)
is just another way of writing .then(response => console.log(response))
but just to be sure I went to the official doc and used the recommend way as well:
axios
.post(url, {test: "0"})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
The problem persists.