I have a flutter app, my code looks like this:
dynamic result = await CloudFunctions.instance.getHttpsCallable(functionName: 'getAllItemsAfterDatetime').call(
<String, dynamic> {"datetime": "1563109861142"}
);
and a JS file:
exports.getAllItemsAfterDatetime= functions.https.onRequest(async (req, res) => {
if (!mysqlPool) {
mysqlPool = mysql.createPool(mysqlConfig);
}
let datetime = req.body.datetime;
if (datetime == null) datetime = req.query.datetime;
if (datetime == null) datetime = req.params.datetime;
if (datetime == null) datetime = "3100000012120000";
mysqlPool.query('SELECT * FROM items as res WHERE datetime > ' + datetime, (err, results) => {
if (err) {
console.error(err);
res.status(500).send(err);
} else {
res.status(200).send({cnt: res.length, data: JSON.stringify(results)});
}
});
I got allways "3100000012120000", so basically I can't get my datetime param back from mobil. It is working in browser. How to do this in a mobil app?
req.parameters is the correct word or WHAT?
Thanks
UPDATE: The solution
//from browser
let datetime = req.body.datetime;
//from mobile
if (datetime == null) datetime = req.body.data.datetime;
//if not set
if (datetime == null) datetime = "3100000012120000";
solution was
//from browser
let datetime = req.body.datetime;
//from mobile
if (datetime == null) datetime = req.body.data.datetime;
//if not set
if (datetime == null) datetime = "3100000012120000";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With