亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何使用 firebase 從我的 Api 發布 GeoPoint

如何使用 firebase 從我的 Api 發布 GeoPoint

慕容森 2023-05-25 18:14:43
我是編碼新手,實際上我正在制作我的第一個 Api。我的問題是我嘗試在我的 firestore 數據庫中發布一些 Geopoint 但它看起來不可能這是我的代碼如下:const db = admin.firestore();const pointGps = new admin.firestore.GeoPoint(Number, Number);app.post('/api/createrdv', (req, res) => {    (async () => {        try {            await db.collection('rvlist').doc() // CREATION AUTO DE L'ID // POUR CREER AVEC ID PERSO ('/' + req.body.id + '/')                .create({                  //id: req.body.id,                    latlong: pointGps({lat: req.body.lat, lng: req.body.lng}),                    name: req.body.name,                    phone: req.body.phone,                    psnumber: req.body.psnumber,                    rvtime: req.body.rvtime,                    vu: req.body.vu                });            return res.status(200).send();        } catch (error) {            console.log(error);            return res.status(500).send(error);        }    })();});錯誤:參數“緯度”的值不是有效數字。同樣的問題我不能將數據庫用于任何時間戳。關于如何做的任何想法,或者這至少可以通過 firestore 實現?我卡住了兩天
查看完整描述

2 回答

?
小唯快跑啊

TA貢獻1863條經驗 獲得超2個贊

嘗試這個:


const db = admin.firestore();



app.post('/api/createrdv', (req, res) => {

    (async () => {

        try {

            await db.collection('rvlist').doc() // CREATION AUTO DE L'ID // POUR CREER AVEC ID PERSO ('/' + req.body.id + '/')

            .create({


                  //id: req.body.id,

                    latlong: new GeoPoint(Number(req.body.lat), 

                                          Number(req.body.lng)),

                    name: req.body.name,

                    phone: req.body.phone,

                    psnumber: req.body.psnumber,

                    rvtime: req.body.rvtime,

                    vu: req.body.vu


                });


            return res.status(200).send();


        } catch (error) {


            console.log(error);

            return res.status(500).send(error);

        }

    })();

});


查看完整回答
反對 回復 2023-05-25
?
BIG陽

TA貢獻1859條經驗 獲得超6個贊

app.post('/api/create', (req, res) => {

(async () => {

? ? try {

? ? ? ? await db.collection('psdata').doc() // CREATION DE L'ID AUTOMATIQUE // POUR CREER AVEC ID PERSO ('/' + req.body.id + '/') //

? ? ? ? ? ? .create({


? ? ? ? ? ? ? //id: req.body.id,

? ? ? ? ? ? ? ? latlong: new admin.firestore.GeoPoint(Number(req.body.lat),

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Number(req.body.lng)),

? ? ? ? ? ? ? ? city: req.body.city,

? ? ? ? ? ? ? ? name: req.body.name,

? ? ? ? ? ? ? ? phone: req.body.phone,

? ? ? ? ? ? ? ? psnumber: req.body.psnumber,

? ? ? ? ? ? ? ? speciality: req.body.speciality,

? ? ? ? ? ? ? ? streetadress: req.body.streetadress,

? ? ? ? ? ? ? ? zipcode: req.body.zipcode,

? ? ? ? ? ? ? ??


? ? ? ? ? ? });


? ? ? ? return res.status(200).send();


查看完整回答
反對 回復 2023-05-25
  • 2 回答
  • 0 關注
  • 160 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號