I would like to debug on my mobile/simulator and point it dynamically to API.
const {manifest} = Expo.Constants;
const api = manifest.packagerOpts.dev
? manifest.debuggerHost.split(':').shift().concat(':3000')
: 'productionurl.com'
export function getEvents(){
return fetch('http://${api}/events')
.then(response => response.json())
.then(events => events.map(e =>({ ...e, date: new Date(e.date)})));
}
I am getting the following error:
undefined is not an object(evaluating'_expo.default.Constants')