AbstractHttpRequest now API compatible with Request

4 views
Skip to first unread message

AJ ONeal

unread,
Oct 30, 2010, 11:31:05 PM10/30/10
to nod...@googlegroups.com, futures-j...@googlegroups.com
Thanks for the idea. AHR can now be used exactly like `request` in node and the browser.

var request = require('ahr');
request(options, callback);

In fact, I added request's test cases to my own.

Here's an example of other features and how to join them together.

request.join(
     request({ uri: '/local-contacts' }),
     request.get("/local-contacts", params, options),
     request.jsonp(FacebookContacts, "jsoncallback", params, options),
     request.jsonp(TwitterContacts, "callback", params)
).when(function (fbcResp, tcResp) {
     var fbc, tc;
     fbc = { err: fbcResp[0], xhr: fbcResp[1], data: fbcResp[2] };
     tc = { err: tcResp[0], xhr: tcResp[1], data: tcResp[2] };
    if (fbc.err || tc.err) {
        console.log(fbc.err);
        console.log(tc.err);
    }
});


http://github.com/coolaj86/abstract-http-request

AJ ONeal
(317) 426-6525

On Fri, Oct 29, 2010 at 11:28 AM, Charlie Robbins <charlie...@gmail.com> wrote:
Neat. Like the cross-platform aspects to the library. Have you considered being more consistent with the new 'request' APIs that are being discussed going into core? The code currently exists here: http://github.com/mikeal/node-utils/tree/master/request/ With the feature branch here: http://github.com/mikeal/node/tree/http-request-merge

-Charlie

On Fri, Oct 29, 2010 at 3:36 AM, AJ ONeal <cool...@gmail.com> wrote:
Changed the URL:
http://github.com/coolaj86/abstract-http-request

JSONP is now working for both node and the browser. jQuery is no longer required, but will be used if available.

Other methods appear to be working just fine as per firebug.

AJ ONeal


On Sun, Oct 24, 2010 at 2:35 AM, AJ ONeal <cool...@gmail.com> wrote:
Abstract HTTP Request is an HTTP Client with very reasonable default settings that works both in Browers and Node.JS.

http://github.com/coolaj86/ahr

ahr.http({
    "url": "http://user:pa...@host.com:8080/p/a/t/h?query=string#hash",
}).when(function (err, data, nativeClient) {
    console.log(err);
    console.log(data);
    // nativeClient is either XMLHttpRequest or Node.Http.Client.Request.Response
});


var flickrApi = "http://api.flickr.com/services/feeds/photos_public.gne?format=json";
ahr.get(flickApi, {tags: "cat", tagmode: "any"})

    .when(function (err, data, xhr) {
        // do stuff
    });

There are a few easy-to-fix quirks that I'll be working out as I develop with this over the next few days, but I wanted to go ahead and get it out tonight.

AJ ONeal


--
You received this message because you are subscribed to the Google Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com.
To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nodejs?hl=en.

--
You received this message because you are subscribed to the Google Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com.
To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nodejs?hl=en.


Reply all
Reply to author
Forward
0 new messages