【问题标题】:Error: could not handle the request with Google Cloud Function and Express错误:无法使用 Google Cloud Function 和 Express 处理请求
【发布时间】:2019-08-21 08:50:59
【问题描述】:

这是我的代码。为什么当我转到我的云函数的 url 时收到此消息:“错误:无法处理请求”,而我没有看到“Hello World!” ?谢谢

exports.simple = (req,res) => {

var express = require('express');
var https = require('https');
var bodyParser = require('body-parser');
var app = express();

module.exports = app;

return app.get('/', (req, res) => res.send("Hello World!"))
    .then((result) => {
     console.log("DONE",result);
     console.log("Delete opportunity");
    })
     .catch((err) => {
      console.log("ERROR",err);
    }) 
};

【问题讨论】:

    标签: node.js express google-cloud-functions


    【解决方案1】:

    我设法通过将所有代码放在默认入口点之外并将app 变量设置为新入口点来使其工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-09
      • 2021-06-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-29
      相关资源
      最近更新 更多