如何使用 firebase 从我的 Api 发布 GeoPoint

我是编码新手,实际上我正在制作我的第一个 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 实现?我卡住了两天


慕容森
浏览 138回答 2
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);        }    })();});

BIG阳

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();
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript