I would like to know if it was possible to execute a function from Firebase Cloud Function on a React Native Expo application (using the SDK)? I tried to install the sdk but I get several errors. If not, is there another way to do it, without the SDK?
If you do not want to install any third party module, then use react native's fetch API:
A simple GET operation would be:
fetch('<Your Firebase Cloud Function URL>')
A POST operation would be done this way:
fetch('<Yout Firebase Cloud Function URL>', {
method: 'POST',
headers: {
...
},
body: JSON.stringify({
...
})
})
Or, there are some popular 3rd party libraries such as axios. Install it using command npm i --save axios and then:
import axios from 'axios'
axios.get('<Your Firebase Cloud Function URL>')
or
axios.post('<Your Firebase Cloud Function URL>', {
...
...
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With