Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can I use react native to build a mobile app with Django rest api?

Tags:

react-native

I am newbie to react native. Recently I am thinking of building a cross-platform mobile app. I am already developing backend rest API in Django. Is it possible to use react native in this case ? If not, what would my other choices ?

like image 872
jyhk Avatar asked Feb 22 '16 19:02

jyhk


1 Answers

Yes, it is. You have to use fetch in order to use your API. The most important thing is that your API returns JSON (ideally) or another response that can be handled by Javascript (HTML, XML, ...).

Here you have a tiny example about how to fetch data from your API in React Native.

 fetch('http://your-django-api-url.com/endpoint?query=id')  
 .then((response) => {
     return response.json()
 })

More information here: https://facebook.github.io/react-native/docs/network.html

like image 178
midudev Avatar answered Sep 21 '22 16:09

midudev