question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fetch Fails on Android, works on IOS

See original GitHub issue

React Native version:

System:
    OS: macOS 10.15.1
    CPU: (4) x64 Intel(R) Core(TM) i7-6567U CPU @ 3.30GHz
    Memory: 47.02 MB / 8.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 10.11.0 - /usr/local/bin/node
    Yarn: 1.10.1 - /usr/local/bin/yarn
    npm: 6.9.0 - /usr/local/bin/npm
    Watchman: 4.7.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.5977832
    Xcode: 11.2.1/11B500 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.8.6 => 16.8.6 
    react-native: 0.60.4 => 0.60.4 
  npmGlobalPackages:
    react-native-cli: 2.0.1
    react-native-git-upgrade: 0.2.7
    react-native-svg: 6.0.0-rc1

Steps To Reproduce

  1. Create API with AWS Lambda and API Gateway
  2. Call the following code:
var headers = {
   'Authorization': 'Bearer ${Cognito.signInUserSession.idToken.jwtToken}'
 }
 console.log("Headers" , headers);
 const qs = `{users(username: "aUserName") {username, leagues {name, start, currentTime, ready, creator, totalPlayers, joinedPlayers, creatorInfo {fullName}, draftPicks{user{username, fullName} order,numTickets}}} }`

 const URL = 'https://someID.execute-api.us-east-1.amazonaws.com/Prod/graphql?query=${qs}';
 return (
   fetch(URL, {
     method: 'GET',
     headers,
   })
  1. Use IOS and Postman, it works fine, on Android I get status 400

Describe what you expected to happen:

I expect the code to work and get 200 response

image

IOS screenshot that shows it works: image

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
quietbitscommented, Feb 27, 2020

I’m getting the same error on RN version 0.61.5 (latest). The exact same call with the same params works on iOS (both device and simulator) and Postman on the web but fails on anything Android (device, emulators with different OS versions). It’s an HTTPS call. It’s also interesting that it works when RN debugger is enabled.

@hramos I can confirm that this is an issue on the latest RN release as well.

0reactions
stale[bot]commented, Jun 6, 2020

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fetch Request not working on android, but working on IOS
Hi, any luck? Facing the same issue, the app working fine on IOS but fetch fails in android giving "[TypeError: Network request failed]"...
Read more >
Fetch and XHR Request working on Android but not on iOS
On android, the fetch-api completed succesfully, with a correct response from the server. My server does have SSL, and I'm sending the request ......
Read more >
Networking
Fetch method will return a Promise that makes it straightforward to write code that works in an asynchronous manner:.
Read more >
fetch() - Web APIs | MDN
The promise resolves to the Response object representing the response to your request. A fetch() promise only rejects when a network error is...
Read more >
Failed to fetch assets Error - Build issue
This is only happening on iOS build android has built successfully. Vignesh_Rajendiran July 15, 2022, 8:35pm ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found