sub*_*as8 7 node.js google-cloud-platform google-cloud-functions
我正在尝试创建一个简单的函数:
我认为 Google Cloud Functions 将是完美的选择,因为我可以用 JS 编写代码,而不必担心服务器部署等问题。
我从来没有真正使用过nodejs/npm所以也许这就是问题所在,但我尝试在线阅读,他们只是提到
npm install package-name
Run Code Online (Sandbox Code Playgroud)
我不确定在 Google Cloud Functions 页面上的哪里可以执行此操作。
我目前正在使用内联编辑器,并且有以下内容:
var fetch = require('node-fetch');
exports.test2 = (req, res) => {
fetch("myURLgoes here").then(function(response){
res.status(200).send('Success:'+response);
});
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
错误:函数崩溃。详细信息:未定义获取
从 Google Cloud Platform 控制台,转到您的云功能。
创建或编辑函数时,您应该有两个文件: - index.js:定义函数的位置 - package.json:定义依赖项的位置。
你的 package.json 一开始是这样的:
{
"name": "sample-http",
"version": "0.0.1"
}
Run Code Online (Sandbox Code Playgroud)
在 package.json 中添加您想要使用命令 npm install 安装的所有模块,如下所示:
{
"name": "sample-http",
"version": "0.0.1",
"dependencies": {
"@material-ui/core": "^4.1.1"
}
}
Run Code Online (Sandbox Code Playgroud)
您可以在 www.npmjs.com 上找到该软件包的最新版本
| 归档时间: |
|
| 查看次数: |
8691 次 |
| 最近记录: |