Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local Fetch GET Network Request Failing #18432

Closed
3 tasks done
ghost opened this issue Mar 18, 2018 · 6 comments
Closed
3 tasks done

Local Fetch GET Network Request Failing #18432

ghost opened this issue Mar 18, 2018 · 6 comments
Labels
🌐Networking Related to a networking API. Ran Commands One of our bots successfully processed a command. Resolution: For Stack Overflow A question for Stack Overflow. Applying this label will cause issue to be closed. Resolution: Locked This issue was locked by the bot.

Comments

@ghost
Copy link

ghost commented Mar 18, 2018

Description
I'm trying to fetch data from my local api's & getting "Network Request Failed". These API's are working fine on POSTMAN. If i replace this URL with url given in [https://facebook.github.io/react-native/docs/network.html], this code works.

componentDidMount(){ return fetch("https://api.kashu.com:4002/api/HomeData/1",{ method: 'GET', headers: { Accept: 'application/json', 'Content-Type': 'application/json', 'x-ibm-client-id' : 'default', 'x-ibm-client-secret': 'SECRET' } }) .then((response) => response.json()) .then((responseJson) => { alert(responseJson); this.setState({ isLoading: false, dataSource: responseJson, }, function(){ }); }) .catch((error) =>{ console.error(error); }); }

Actual Response if API is run by POSTMAN or any client
{ "data": "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\\'s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.", "id": 1 }

Environment

Environment: OS: Windows 10 Node: 8.10.0 Yarn: Not Found npm: 4.6.1 Watchman: Not Found Xcode: N/A Android Studio: Not Found Packages: (wanted => installed) react: 16.2.0 => 16.2.0 react-native: 0.52.0 => 0.52.0
Platform: Testing App on iPhone6 using Expo Client
API : Loopback API's hosted on same local system, changed hostname - api.kashu.com(pointed to 127.0.0.1)

Steps to Reproduce

  1. Tried to make GET Request to Local Loopback.js API from 0.54 version of React Native
  2. Threw Network Error.

Expected Behavior

  1. API should be working.

Actual Behavior

Tried to make GET Request to Local Loopback.js API from 0.54 version of React Native & React native threw Network Error.
iOS 6(Expo Client) Error Information -
whatsapp image 2018-03-18 at 6 30 01 am

@react-native-bot
Copy link
Collaborator

Thanks for posting this! It looks like your issue may be incomplete. Are all the fields required by the Issue Template filled out?

If you believe your issue contains all the relevant information, let us know in order to have a maintainer remove the No Template label. Thank you for your contributions.

How to ContributeWhat to Expect from Maintainers

@react-native-bot react-native-bot added No Template 📋 Ran Commands One of our bots successfully processed a command. labels Mar 18, 2018
@react-native-bot
Copy link
Collaborator

Thanks for posting this! It looks like your issue may be missing some necessary information. Can you run react-native info and edit your issue to include these results under the Environment section?

Thank you for your contributions.

@react-native-bot react-native-bot added Needs More Information ❔ Ran Commands One of our bots successfully processed a command. labels Mar 18, 2018
@Alastair-smith2
Copy link

Alastair-smith2 commented Mar 18, 2018

If you trying to access localhost, you'll need to put your ip address from experience. This post should help explain why - #10404 (comment).

@hramos hramos added ⏪Old Version Resolution: For Stack Overflow A question for Stack Overflow. Applying this label will cause issue to be closed. labels Mar 19, 2018
@react-native-bot react-native-bot added the 🌐Networking Related to a networking API. label Mar 19, 2018
@react-native-bot
Copy link
Collaborator

This issue looks like a question that would be best asked on Stack Overflow.

Stack Overflow is amazing for Q&A: it has a reputation system, voting, the ability to mark a question as answered. Because of the reputation system it is likely the community will see and answer your question there. This also helps us use the GitHub bug tracker for bugs only.

Will close this as this is really a question that should be asked on Stack Overflow.

@yoaquim
Copy link

yoaquim commented Jun 17, 2018

I'm having this same issue (using the Expo app on an iPhone 7 Plus).

My fetch function works perfectly: I've used it many times before.

Everything works on Simulator on my MacBook Pro (didn't even have to change to 127.0.0.1, worked with localhost), but get a:

[Unhandled promise rejection: TypeError: Network request failed]
- node_modules/react-native/node_modules/whatwg-fetch/fetch.js:441:29 in onerror
- node_modules/event-target-shim/lib/event-target.js:172:43 in dispatchEvent
- ... 8 more stack frames from framework internals

when trying to run on my iPhone.

Suggestions?

@paulmthiebauth
Copy link

@yoaquim did you ever solve your issue? Im using what I thought to be the proper IPv4 # instead of localhost but I still get network request errors

@facebook facebook locked as resolved and limited conversation to collaborators Mar 19, 2019
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Mar 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🌐Networking Related to a networking API. Ran Commands One of our bots successfully processed a command. Resolution: For Stack Overflow A question for Stack Overflow. Applying this label will cause issue to be closed. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

5 participants