Tag: 端点

如何在nodejs中的端点调用中传递一个variables

我有一个variables,例如var merchanttoken = requestConfig.merchant_connect_token ,如何通过它时,呼叫端点例如 request.get('http://pi.call/v2/{merchanttoken}/info, function) 我需要在URL中传递variables。

NodeJS API通过ID获取。 如何检测项目未find?

我正在开发一个GET端点来从数据库(dynamoDB)中获取元素。 我使用Swagger在我的api中定义数据模型。 这是我的控制器中的operationId方法: getInvoiceConfigById: function(req, res) { var myId = req.swagger.params.id.value; // InvoiceConfig is a dynamoDb model // providerId attribute is the unique key of the db table InvoiceConfig.scan('providerId') .eq(myId) .exec(function (err, config) { if (err) { console.log("Scan InvoiceConfig error"); throw err; } res.status(200).send(config); }); } 如果找不到id,我想发送404消息。 我在swagger-ui中注意到响应的主体是空的 Response Body [] 当在数据库中找不到id时。 如何在我的代码中检测到ID未find时? 我试图检查响应的主体是否为空: 如果(!(config.body)) […]

在节点JS中,我如何创build一个端点传递? 我使用快递和http

在节点JS中,我如何创build一个端点传递? 我使用快递和http整个应用程序将只是一系列通过端点。 这是我的代码 // the real endpoint is somewhere else. // for example http://m-engine.herokuapp.com/api/getstudents2 var http = require('http'); var options = { host: 'http://m-engine.herokuapp.com', path: '/api/getstudents2', method: 'GET' }; app.get('/api/getstudents', function(req, res){ // now past the request through http.request(options, function(response2) { response2.on('data', function (data) { res.json(data); }); }).end(); });

如何检查我的node.js服务器在哪个URL上运行?

我有两台服务器: db.mydomain.com和 db2.mydomain.com(用于开发) 我如何检查我的代码在哪个服务器上运行? 我想对生产数据做一个备份,但不是从开发者那里进行备份。 任何想法如何做到这一点? 谢谢。