DEV Community

Discussion on: How to get data from an MySQL database in React Native

 
saulojoab profile image
Saulo Joab

You can't use localhost because you're running the app in your cellphone. The server is running on your computer. If you use locahost the app will understand that the server is running on your cellphone, which is not correct. Here's how you should do it:

async fetch(){ 
    await fetch('http://yourComputerIPhere:3000/users')
      .then(response => response.json())
      .then(output => (this.setState({output}))
    )}