首页 > 解决方案 > 如何在反应中向 Firebase REST API 发送 POST 请求

问题描述

我正在尝试使用 OAuth 凭据登录,这涉及向 Auth verifyAssertion 端点发出 HTTP POST 请求。我将如何在语法上执行此操作?我正在尝试遵循这个 firebase 文档,但他们使用 curls 作为示例。

https://firebase.google.com/docs/reference/rest/auth/#section-sign-in-with-oauth-credential

端点是https://identitytoolkit.googleapis.com/v1/accounts:signInWithIdp?key=[API_KEY]

标签: reactjsfirebaserestexpressfirebase-authentication

解决方案


您可以选择本机 fetch api

window.fetch('https://url-you-want-to-post-to.com/', {method: 'POST', body: { //body data } })

或者你可以使用第三方库,比如 axios(虽然你需要先 npm install 再导入)


推荐阅读