我正在尝试使用https模块中的get
方法向API发出请求。
关注HTTPS request in NodeJS,我有很长的路要走,但我的请求似乎没有包含查询参数......
使用上面的示例,使用我的mods:
var $q = require('q'),
_ = require('lodash'),
path = require('path'),
Qs = require('qs'),
path = require('path'),
uuid = require('node-uuid'),
https = require('https');
var params = {
schema: '1.0',
form: 'json',
username: 'name'
}
var options = {
host: 'openshift.redhat.com',
port: 443,
path: '/broker/rest/api',
query: params
};
var req = https.get(options, function(res) {
答案 0 :(得分:8)
根据https://nodejs.org/api/https.html#https_https_request_options_callback,没有名为“查询”的选项。您需要将查询参数包含在“路径”中。
请求路径。默认为'/'。应包括查询字符串(如果有)。例如。 '/index.html?page=12'。