Value from async function in URL inside Javascript fetch
up vote
1
down vote
favorite
The below code is inside a react native application: Let's say I have the below function in API.js file: export function getUsers() { return fetch(BASE_URL+'/users') .then(response => { return response; }) } My application's BASE URL is dynamic or can be customized by the user. Which means, I am keeping this value in AsyncStorage of my application. Which means, AsyncStorage.getItem('BASE_URL') holds the value for my actual BASE_URL. Problem is, the getItem function itself is a promise function. That is only wrapping it to a promise syntax will make it work. For example, AsyncStorage.getItem('BASE_URL').then(url => { console.log(url) //gets the URL here properly }); My problem is, how to actually replace the BASE_URL variab...