Do Google Cloud Platform HTTP Functions Support Route Parameters?

后端 未结 4 1826
野性不改
野性不改 2021-02-20 16:25

This is a bit simpler a question than I tend to like to come here with but I\'ve been driving myself up the wall trying to find an answer to this and I absolutely cannot-

<
4条回答
  •  眼角桃花
    2021-02-20 17:01

    First Create a Handler function,

    function bookIdHandler(req,res){
        let bookId= req.params.bookId;
    
        //your code goes here
    }
    

    You can just pass an Express App object to cloud function routes

    const express = require('express');
    
    const app = express();
    
    app.get('users/:userId/:bookId', bookIdHandler);
    //++ any other express endpoints
    
    
    // Expose Express API as a single Cloud Function:
    exports.widgets = functions.https.onRequest(app);
    

    Ref:How its mentioned in firebase docs

提交回复
热议问题