i've launched local datastore emulatior , although wrote , test gcf remote datastore instance (not emulated one). i'm trying use locally launched datastore instance testing puprposes, requests still going cloud instance of datastore.
here code.
const db = require("@google-cloud/datastore")(); exports.signup = (req, res) => { if(!req.body.firstname || !req.body.lastname || !req.body.email) { res.status(400).send("incorrect user data passed"); } else { let key = db.key("user"); console.log("key: ", key); db.insert({ key: key, data: { firsname: req.body.firsname, lastname: req.body.lastname, email: req.body.email } }, (err, apiresponse) => { console.log(apiresponse); if(err) { res.status(400).json({ message: "error occured during creation" }); } else { res.status(200).json({ message: `created under ${apiresponse}` }); } }); } };
i know apiendpoint (link on documentation) parameter in datastore instance configuration object. should passed explicitly in code? though there should environment variable tell default configuration search datastore emulator first, , try use cloud one.
Comments
Post a Comment