-1

I need you help. For several days I have spent hours and hours trying, and looking for a solution but nothing.

I have to make a network request to use the TMDB API. So I do this (for example):

    const url = 'https://api.themoviedb.org/3/movie/550?api_key=XXXXXXXXX'
console.log(url)

return fetch(url,{
    method: 'GET',
    headers: {
        Accept: '*/*',
        'Content-Type': 'application/json',
        'accept-encoding': 'gzip, deflate, br'
    }
})
    .then((response) => {
        console.log(response)
        response.json()
    })
    .catch((error) => {
        console.error(error)
    })
    .finally(() => {
        console.log('fini')
    })

But I never have response. I have try with fetch and Axios, but it's always the same: no response, no error, noting. The request works when I test it in my browser, it works on Postman and cURL, but not in my app.

For information I'm using an Android emulator, and I added android:usesCleartextTraffic="true" in the AndroidManifest file.

This is not my first React Native app and I never had this problem before.

Thank you in advance for taking the time to read me !

PS: I add a capture of the test made on jsfiddle.net and its equivalent on the android emulator.

Test on jsfiddle.net

--

Test on Android emulator

Paul Angot
  • 11
  • 6
  • Are you sure that's invoked? If it is called then it must give any response. Try applying debugger in the function to check the same. And if that doesn't work, please share snack link or GitHub link to reproduce the error. – Rohit Aggarwal Sep 13 '22 at 04:17
  • Hey! Can you share the code somewhere? so that i can check ? – Shail Patel Sep 13 '22 at 08:33

1 Answers1

0

I don't really know why, but my problem is solved.

I installed a debugger in order to analyze the network requests and see what could be the problem, and once installed, without changing the code, the problem was no longer present...

I followed the procedure of this post: https://stackoverflow.com/a/55450655/13052339

Paul Angot
  • 11
  • 6