Here's my implementation, I'm storing the baseURL on my firestore database. I used to sign in anonymously in order to get the url. But on calling the firestore, my app crashes without any error, warning, etc.
import {create} from 'apisauce';
import auth from '@react-native-firebase/auth';
import firestore, {firebase} from '@react-native-firebase/firestore';
const apiClient = create({
method: 'POST',
});
apiClient.addAsyncRequestTransform(async request => {
await auth()
.signInAnonymously()
.then(() => {
console.log('success');
})
.catch(error => {
console.log(error);
});
const url = await firestore()
.collection('service_url')
.doc('service_url')
.get()
.then(document => console.log(document.data))
.catch(error => console.log(error));
console.log(url);
request.baseURL = url;
auth().signOut();
});
export default apiClient;
The problem I faced was the okHTTP. It was not working with Android API 30. So, after so much workaround, I added the okhttp dependency to my project. That solved my error.