equal
deleted
inserted
replaced
|
1 YUI.add('yql-nodejs', function (Y, NAME) { |
|
2 |
|
3 /** |
|
4 * NodeJS plugin for YQL to use native request to make requests instead of JSONP. |
|
5 * Not required by the user, it's conditionally loaded and should "just work". |
|
6 * @module yql |
|
7 * @submodule yql-nodejs |
|
8 */ |
|
9 |
|
10 var request = require('request'); |
|
11 |
|
12 //Over writes Y.YQLRequest._send to use request instead of JSONP |
|
13 Y.YQLRequest.prototype._send = function (url, o) { |
|
14 request(url, { |
|
15 method: 'GET', |
|
16 timeout: o.timeout || (30 * 1000) |
|
17 }, function(err, res) { |
|
18 if (err) { |
|
19 //The signature that YQL requires |
|
20 o.on.success({ |
|
21 error: err |
|
22 }); |
|
23 } else { |
|
24 o.on.success(JSON.parse(res.body)); |
|
25 } |
|
26 }); |
|
27 }; |
|
28 |
|
29 |
|
30 }, '@VERSION@'); |