Search code examples
iosreact-nativeexpressaxios

API get request fails, but post, put, delete work


Environment and Settings:

  • react-native 0.57
  • expressjs for server
  • using axios for api request
  • set timeout 10000ms
  • the request is a json data with username and small other infos
  • http request (not https)

I'm developing a small react native project and now having a trouble with "api GET request".

It's all perfect for POST, PUT, DELETE actions but only the GET request returns timeout error in the server log with:

"BadRequestError: request denied" .

The same code on Android works just fine, but it only happens on iOS.

I've set NSAllowsArbitraryLoads to true and also NSExceptionDomains just in case but neither of them solved the problem.


Solution

  • Ok, got a solution.

    It was because of an empty object on body when sending 'GET' request. checking if it is empty and making it undefined solved the problem.