firebase 我怎样从我的数据库添加数据到服务器的express get

ffvjumwh  于 2023-02-16  发布在  其他
关注(0)|答案(1)|浏览(95)

所述服务器

import app from "../firebase/firebaseCon";
import analytics from "../firebase/firebaseCon";
const express = require("express");

const ex = express();

ex.get("/store", (req, res) => {
  const store = [
    { id: 1, firstname: "hamdan" },
    { id: 1, firstname: "hamdan" },
    { id: 1, firstname: "hamdan" },
  ];
  res.json(store);
});

ex.listen(5000, () => {
  console.log("hello");
});

所述火座

import { initializeApp } from "firebase/app";
import { getAnalytics } from "firebase/analytics";
const firebaseConfig = {
  apiKey: "",
  authDomain: "",
  projectId: "",
  storageBucket: "",
  messagingSenderId: "",
  appId: "",
  measurementId: "",
};

export const app = initializeApp(firebaseConfig);
export const analytics = getAnalytics(app);

上面的两个代码都在单独的文件中,每当我试图要求或导入firebase文件到服务器时,我会得到一个错误,应用程序停止,错误中没有那么多描述,它只说有一个内部错误
错误

App.js:14          GET http://localhost:3000/store 500 (Internal Server Error)
componentDidMount @ App.js:14
commitLayoutEffectOnFiber @ react-dom.development.js:23305
commitLayoutMountEffects_complete @ react-dom.development.js:24688
commitLayoutEffects_begin @ react-dom.development.js:24674
commitLayoutEffects @ react-dom.development.js:24612
commitRootImpl @ react-dom.development.js:26823
commitRoot @ react-dom.development.js:26682
finishConcurrentRender @ react-dom.development.js:25981
performConcurrentWorkOnRoot @ react-dom.development.js:25809
workLoop @ scheduler.development.js:266
flushWork @ scheduler.development.js:239
performWorkUntilDeadline @ scheduler.development.js:533

代理问题

Could not proxy request /store from localhost:3000 to http://localhost:5000/.
8cdiaqws

8cdiaqws1#

express.listen从端口5000更改为端口3000
像这样

ex.listen(3000, () => {
  console.log("hello");
});

相关问题