我使用Postman测试以下代码。 插入进展顺利,但服务器将我发送回: 错误:无法处理请求
exports.insertMesure = functions.https.onRequest((req, res) => {
const identifiant = req.body.identifiant;
const temperatureAir = req.body.temperatureAir;
const humiditeSol = req.body.humiditeSol;
const humiditeAir = req.body.humiditeAir;
const niveauEau = req.body.niveauEau;
const phSol = req.body.phSol;
const mesure = {
temperatureAir: temperatureAir,
humiditeSol: humiditeSol,
humiditeAir: humiditeAir,
niveauEau: niveauEau,
phSol: phSol
};
const dbRef = admin.database().ref('/users/' + identifiant + '/mesures');
dbRef.push(mesure)
.then(snapchot => {
return snapchot;
})
.catch(err => {
res.send('Error: ' + err);
});
});
我通过邮递员发送以下数据:
{
"identifiant": "talla",
"temperatureAir": 45,
"humiditeSol": 23,
"humiditeAir": 106,
"niveauEau": 55,
"phSol": 6
}
请帮助我
答案 0 :(得分:0)
您的服务器端脚本未将任何内容发送回调用方。您可能希望发送回状态代码以指示数据库写入已成功完成:
SqlConnection