Error: could not handle the request with Google Cloud Function and Express

元气小坏坏 提交于 2020-01-16 18:01:07

问题


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

回答1:


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.



来源:https://stackoverflow.com/questions/57587844/error-could-not-handle-the-request-with-google-cloud-function-and-express

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!