简体   繁体   English

错误:无法使用Google Cloud Function和Express处理请求

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

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!" 为什么当我转到云函数的URL时收到以下消息:“错误:无法处理请求”,而我却没有看到“ 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);
    }) 
};

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. 我设法通过将所有代码放在默认入口点之外,并将app变量设置为新入口点来使其工作。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Firebase 云函数:“错误:无法处理请求” - Cloud Functions for Firebase: 'Error: could not handle the request' 云功能-无法处理请求 - Cloud functions - could not handle the request Express + Multer + Google Cloud Storage 错误:“需要回调函数” - Express + Multer + Google Cloud Storage Error: “Requires a callback function” Angular Functions 函数导致“无法处理请求”错误 - Angular Functions function resulting in “could not handle the request” error Google Cloud Function CORS 发出 POST 请求时出错 - Google Cloud Function CORS error when making POST request Google云功能-存储-删除图像-“ ApiError:请求期间出错” - Google Cloud Function - Storage - Delete Image - “ApiError: Error during request” 如何在 Google Cloud Functions 中调用 Express function? - How to call an Express function in Google Cloud Functions? 邮递员在向 Firebase 函数发布请求时说“错误:无法处理请求” - Postman says "Error: could not handle the request" when posting request to Firebase function 未定义NodeJS Google Cloud功能请求 - NodeJS google cloud function request not defined 从谷歌云返回的错误请求 function - Bad request returned from google cloud function
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM