Slim API doesn't works on iPhone

I designed APIs with the 3rd version of Slim. These APIs works on Android devices and desktop but doesn’t works on iOS devices (iPhone, iPad, etc…)

Someone can help me ?

Hi Romdja,

Welcome to the Slim Forum.

We will need quite a bit more information than “doesn’t work”. What is the error? What is your setup? What does your request look like? Show some code? Can you reduce it down to a simple example that isn’t working?

On the first pic, there is the route I’m trying to get and on the second, the logic.

When I’m trying on laptop or android devices it works very well but on iPhone (my iPhone 7) it doesn’t works, I can’t got any response. On my mobile phone, I can’t see the console log so I can’t know the problem

You can access the console of your iPhone by connecting it to your Mac via lightning cable, then going into Safari --> Develop --> (your iPhone). From that you can also see the request and response headers to see if they match what you expected.

If the Develop menu isn’t active in Safari you can turn it on from Safari’s Preferences near the bottom of the Advanced tab.

You may also find more information about the error from your webserver’s error or access log.

Hello @tflight, I did it.

The error : Failed to load resource: cannot parse response

Does the content type being returned match the content type of the response? I’ve heard of this before on servers that gzip javascript but then don’t set the content type appropriately.

Where do you host your API? I’ve heard that iOS devices with a bad internet connection in combination with DigitalOcean can cause problems with some JS files.

Also GZIP could be a problem for some iOS devices.

According to your screenshot you use JSON_UNESCAPE_UNICODE for json_encode. Try to remove this parameter.

Have you tried to simulate the request using Postman?

Hello @odan

I tried on Postman, it works perfectly. I also retract the JSON_UNESCAPE_UNICODE parameter, but it still doesn’t work on iOS

I don’t know. How can I check it ?

With the iPhone connected to a Mac, in Safari go to Develop --> Show Page Resources. Then call the API. In the Resources tab you should see the request and response headers. Check those and the Type to see if they match. If gzip is enabled in your server try turning it off to see if that is the issue.