我尝试注册并登录 firebase 。我使用Firebase (fire-store)、postman、express(REST API)。
我的代码(index.js)
const functions = require("firebase-functions");
const admin = require("firebase-admin");
admin.initializeApp(config);
// i'm not provide the config data here, but initialized in my actual code.
const express = require("express");
const app = express();
let db = admin.firestore();
// Signup route
app.post('/signup', (req,res) => {
const newUser = {
email: req.body.email,
password: req.body.password,
confirmPassward: req.body.confirmPassword,
handle: req.body.handle
};
let token, userId;
db.doc(`/users/${newUser.handle}`)
.get()
.then(doc => {
if(doc.exists) {
return res.status(400).json({ hanldle: 'this hanlde is already …Run Code Online (Sandbox Code Playgroud) node.js express firebase google-cloud-functions google-cloud-firestore