簡體   English   中英

Firebase雲功能和React Native

[英]Firebase Cloud Function and React Native

我想知道是否可以在React Native Expo應用程序上使用Firebase Cloud Function執行功能(使用SDK)? 我嘗試安裝SDK,但出現了幾個錯誤。 如果沒有,沒有SDK,還有另一種方法嗎?

如果您不想安裝任何第三方模塊,請使用react native的fetch API:

一個簡單的GET操作將是:

fetch('<Your Firebase Cloud Function URL>')

POST操作將通過以下方式完成:

fetch('<Yout Firebase Cloud Function URL>', {
    method: 'POST',
    headers: {
        ...
    },
    body: JSON.stringify({
        ...
    })
})

或者,有一些流行的第三方庫,例如axios 使用命令npm i --save axios安裝它,然后:

import axios from 'axios'

axios.get('<Your Firebase Cloud Function URL>')

要么

axios.post('<Your Firebase Cloud Function URL>', {
    ...
    ...
})

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM