小编Mar*_*son的帖子

如何从Google Cloud Functions(nodeJS)发送HTTP请求

这可能是一个简单的问题,但我是云功能/节点编程的新手,还没有找到正确的文档.

如何编写将收到HTTP请求但随后将HTTP请求发送到其他端点的Google云功能?例如,我可以将HTTP触发器发送到我的云功能(https://us-central1-plugin-check-xxxx.cloudfunctions.net/HelloWorldTest).在项目的后期,我将弄清楚如何实现延迟.但后来我想回复一个新的HTTP请求到另一个端点(https://maker.ifttt.com/trigger/arrive/with/key/xxxx).我怎么做?

exports.helloWorld = function helloWorld(req, res) {
  // Example input: {"message": "Hello!"}
  if (req.body.message === undefined) {
    // This is an error case, as "message" is required.
    res.status(400).send('No message defined!');
  } else {
    // Everything is okay.
    console.log(req.body.message);
    res.status(200).send('Success: ' + req.body.message);
    // ??? send a HTTP request to IFTTT endpoint here
  }
};
Run Code Online (Sandbox Code Playgroud)

httprequest node.js google-cloud-functions

8
推荐指数
5
解决办法
1万
查看次数

将JSON数据存储为Azure表存储中的列

如何格式化我的json数据和/或更改我的功能,以便将其存储为Azure表存储中的列?

我正在向IoT中心发送一个json字符串:

{"ts":"2017-03-31T02:14:36.426Z","timeToConnect":"78","batLevel":"83.52","vbat":"3.94"}
Run Code Online (Sandbox Code Playgroud)

我运行示例函数(在Azure Function App模块中)将数据从IoT中心传输到我的存储帐户:

    'use strict';

// This function is triggered each time a message is revieved in the IoTHub.
// The message payload is persisted in an Azure Storage Table
var moment = require('moment');

module.exports = function (context, iotHubMessage) {
   context.log('Message received: ' + JSON.stringify(iotHubMessage));
   context.bindings.deviceData = {
   "partitionKey": moment.utc().format('YYYYMMDD'),
      "rowKey": moment.utc().format('hhmmss') + process.hrtime()[1] + '',
      "message": JSON.stringify(iotHubMessage)
   };
   context.done();
};
Run Code Online (Sandbox Code Playgroud)

但是在我的存储表中,它显示为单个字符串而不是分成列(如存储资源管理器中所示).

Azure存储资源管理器

如何将其插入ts,timeToConnect,batLevel和vbat的列中?

json azure azure-table-storage azure-functions

6
推荐指数
2
解决办法
5309
查看次数

console.log信息在哪里显示Google Cloud功能

运行Google Cloud功能时,如何查看console.log的打印内容?有云控制台吗?

exports.helloWorld = function helloWorld(req, res) {
  // Example input: {"message": "Hello!"}
  if (req.body.message === undefined) {
    // This is an error case, as "message" is required.
    res.status(400).send('No message defined!');
  } else {
    // Everything is okay.
    console.log(req.body.message);
    res.status(200).send('Success: ' + req.body.message);
  }
};
Run Code Online (Sandbox Code Playgroud)

javascript google-cloud-endpoints google-cloud-platform

5
推荐指数
1
解决办法
3189
查看次数

如何查找和修复未捕获的异常?

我不知道如何弄清楚未捕获的异常来自何处.我查看了stackoverflow帖子,并尝试寻找几个解决方案.据我所知,我的活动,"监视器",列在我的清单中,它是包的一部分.但是当我启动"Monitor"活动时,我得到一个空指针异常.我应该寻找什么才能找到这个例外?

02-03 21:44:14.192: E/Trace(19701): error opening trace file: No such file or directory (2)
02-03 21:44:14.262: I/BugSenseHandler(19701): Registering default exceptions handler
02-03 21:44:14.633: I/Setup(19701): Setup activity created
02-03 21:44:14.813: I/BugSenseHandler(19701): Flushing...
02-03 21:44:14.823: I/BugSenseHandler(19701): Registering default exceptions handler
02-03 21:44:15.023: W/BugSenseHandler(19701): Transmitting ping Exception No peer certificate
02-03 21:44:15.403: I/Adreno200-EGLSUB(19701): <ConfigWindowMatch:2087>: Format RGBA_8888.
02-03 21:44:15.594: E/(19701): <s3dReadConfigFile:75>: Can't open file for reading
02-03 21:44:15.594: E/(19701): <s3dReadConfigFile:75>: Can't open file for reading
02-03 21:44:19.318: W/dalvikvm(19701): threadid=1: thread exiting with uncaught exception …
Run Code Online (Sandbox Code Playgroud)

android uncaught-exception

0
推荐指数
1
解决办法
562
查看次数