shutterstock / armrest Goto Github PK
View Code? Open in Web Editor NEWA high-level HTTP / REST client for Node
License: MIT License
A high-level HTTP / REST client for Node
License: MIT License
Modifying args.query
directly can cause unintended consequences for the user. For example, if a user is running parallel or in-series calls using the same query object, then deleting fields from this object (see line# 99 in /lib/index.js
) will cause subsequent calls to fail.
I have a client configured like below:
var client = armrest.client({
base: 'http://www.example.com/api',
});
Then I make a request to /foo
:
client.get({
url: '/foo',
success: resolve,
error: reject
});
The full URL that should be constructed is http://www.example.com/api/foo
, but the actual URL is http://www.example.com/foo
, which is invalid.
I can manually add /api
to each request, but the README indicates the base path will be preserved.
Is this a bug, or am I holding it wrong?
Code
var armrest = require('armrest');
var http = require('http');
var client = armrest.client('http://127.0.0.1:8000');
http.createServer(function(req, res) {
res.writeHead(404);
if (req.url.match(/empty/)) {
res.end();
} else if (req.url.match(/json/)) {
res.end('{}');
} else {
res.end('plain');
}
}).listen(8000, '127.0.0.1');
client.get({
url: '/empty',
complete: function(err) {
console.log('empty (plain):', err ? 'has error' : 'no error');
},
});
client.get({
url: '/json',
complete: function(err) {
console.log('empty (json):', err ? 'has error' : 'no error');
},
});
client.get({
url: '/',
complete: function(err) {
console.log('not empty:', err ? 'has error' : 'no error');
},
});
Output
$ node test.js
[2014-05-28 10:21:05.856] [WARN] armrest - GET http://127.0.0.1:8000/empty 404 14ms
empty (plain): no error
[2014-05-28 10:21:05.858] [WARN] armrest - GET http://127.0.0.1:8000/json 404 14ms {} | [object Object]
empty (json): has error
[2014-05-28 10:21:05.859] [WARN] armrest - GET http://127.0.0.1:8000/ 404 15ms plain | Error: Could not deserialize data: plain
not empty: has error
I've been using armrest for a few months and was still on v2.2.2
. All of a sudden I noticed this project is at v4.2.1
and I have no idea what was changed, fixed, broken, added in that short amount of time.
Is it possible for you guys to add a Changelog for future releases, so it's much easier to understand without having to view the source code / commit history?
Thanks!
Who can currently publish this repository?
request
is a bit ambiguous when it comes to determining if the authentication parameters are provided. Its documentation recommends the passing of key-values but uses said object and blobs it into the request URI.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.