I'm using firebase-admin to retrieve data and using Netlify Lambda functions to call the service. This is basically it.
Here is my code:
exports.handler = (event, context, callback) => {
const { id = "toronto" } = event.queryStringParameters;
const cityRefs = dbInstance.collection("cities");
console.log("req.params.id", id);
if (id === "mumbai") {
console.log("in here", id);
let cityRef = cityRefs.doc("id1");
return cityRef
.get()
.then(doc => {
if (!doc.exists) {
console.log("No such document!");
} else {
console.log("Document data:", doc.data());
callback(null, {
statusCode: 200,
body: doc.data()
});
}
})
.catch(err => {
console.log("Error getting document", err);
callback(err);
});
}
}
I keep getting the below error. I'm not exactly sure I'm doing wrong.
Function invocation failed: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type number
in herebut then right after that the error occursdoc.data()inJSON.stringify(). You may also get more responses (and lots of friendly folks) on the Netlify Community! community.netlify.com/c/netlify-platform/functions