1

I am currently implementing Rest API standards in firebase functions. I am searching for an option for passing id as params. But I am not sure where my current Implementation was sufficient to change like that.

My code looks like this.

export const user = functions.https.onRequest(userModule);

and the URL will be like

https://firebaseapp<baseurl>/user

I need to pass the user id in the URL(not as query param)

expected URL

https://firebaseapp<baseurl>/user/{userId}

Is there any way to make the URL look like the above in firebase functions?

1
  • Can you share what userModule is? If that's an instance of Express app then you can follow my answer. Commented Apr 13, 2022 at 18:36

1 Answer 1

1

You can use Request object from Express to access the path parameters using params property as shown below:

app.get("/user/:userId", (req, res) => {
  console.log("Path params", req.params); // { userId: "USER_ID" }
  res.json(req.params);
}));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.