Can't use api parameter!

This my query

exports = function(arg) {
const mongodb =““);
const mycollection = mongodb.db(”
return mycollection.findOne({user_name: arg },{_id:0, password: 1 });

When i test it in Testing Console it works good !
but when test it in postman it gets null !

Getting the same.
Can someone from mongodb please take a look?
I can’t get any endpoint that requires a parameter (function argument) to work.
Endpoints that don’t require a parameter work fine.

I think I figured it out.
Try this:

exports = function(request) {
const mongodb =““);
const mycollection = mongodb.db(””).collection(“********”);
return mycollection.findOne({user_name: request.query.arg},{_id:0, password: 1 });

I noticed that linking a function to an https endpoint doesn’t mean that the api parameters are parsed automatically. The https endpoint send the request object to your function, which you need to access manually to find your api parameters.
In the code above, “arg” is the parameter name you use in the fetch link.

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.