错误:无法使用 Google Cloud Function 和 Express 处理请求 [英] Error: could not handle the request with Google Cloud Function and Express

查看:14
本文介绍了错误:无法使用 Google Cloud Function 和 Express 处理请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码.为什么当我转到我的云函数的 url 时,我收到这条消息:错误:无法处理请求"并且我没有看到Hello World!"?谢谢

this is my code. Why when I go to the url of my cloud function I receive this message :"Error: could not handle the request" and I didn't see "Hello World!" ? Thanks

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);
    }) 
};

推荐答案

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

I managed to make it work by placing all the code outside the default entry point and by setting the app variable as the new entry point.

这篇关于错误:无法使用 Google Cloud Function 和 Express 处理请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆