try enabling cors and setting application/json headers. You need to have cors enabled to reach a 3rd ip. Also you need to fit their headers. Try looking deeper into the requirements of the weather api and try with POSTMAN first, and if that works you can get the headers using the output "code" selection. You dont have to make an account with postman, even though it tries to make you.


Thanks to all the help, I think pavan kumar's comment pointed me to the correct direction. After adding this line let coord = req.body.coord; to the post method, I was able to see the request body by console.log(coord):

{ latitude: 50, longitude: -2.1 }

The 500 internal server error was caused by calling coord[0] and coord[1], as coord was an object rather than an array. The error disappeared after changing to

coordinates = `lat=` + coord.latitude + `&lon=` + coord.longitude;

Thanks again.

Related Query

More Query from same tag