Skip to content Skip to sidebar Skip to footer

Developing Nativescript App With Local Api

This may be a silly question and I am very new to NativeScript. I have a sample project up. Trying to do a simple get request to a local api. This is a website setup on my local de

Solution 1:

return fetch(config.apiUrl + "events", { - so the fetch request is expecting the first argument to be a URL. So where config.apiUrl is defined is where the request goes. You can change this to point to the localhost instance of your server you are running.


Solution 2:

So I have found the issue, thought I would post it. The problem wasn't my endpoints or my NS install. It is because Android Emulators out of the box cannot reference local sites running on your dev machine without some modification to the hosts settings on the Emulator. This process is explained here but I want to emphasize for anyone having the same issue.

Android emulators do not support access to local machine sites out of the box as explained here: https://developer.android.com/studio/run/emulator-networking.html

It needs to be setup through the device EVERYTIME unless someone has a solution to set this up only once, I would love to see it shared here.

There are serveral solutions outlining similar steps but I have had issues on every single one. Here is one that outlines the gist of the issue: http://sadhanasiblog.blogspot.in/2012/07/local-environment-setup-for-android.html

Thanks for the help.


Post a Comment for "Developing Nativescript App With Local Api"