Reputation: 6745
Any idea why this request would be failing in nodejs
considering it works using curl
? Maybe I've not mapped the request correctly.
Request using curl
cli:
curl -u myusername:mypassword https://db.com/dbname/_all_docs
Response, the documents in db:
{
rows: [
..
]
}
Request using https
module in nodejs
:
var requestOptions = {
host: 'db.com',
path: 'dbname/_all_docs',
method: 'GET',
auth: 'myusername:mypassword'
};
Response code is 502
:
{"error":"bad_gateway","reason":"Bad gateway"}
Upvotes: 0
Views: 151
Reputation: 106696
Your path
should start with a forward slash:
var requestOptions = {
host: 'db.com',
path: '/dbname/_all_docs',
method: 'GET',
auth: 'myusername:mypassword'
};
Upvotes: 1