src/cm/media/js/lib/yui/yui_3.10.3/build/yql-nodejs/yql-nodejs-debug.js
changeset 525 89ef5ed3c48b
equal deleted inserted replaced
524:322d0feea350 525:89ef5ed3c48b
       
     1 /*
       
     2 YUI 3.10.3 (build 2fb5187)
       
     3 Copyright 2013 Yahoo! Inc. All rights reserved.
       
     4 Licensed under the BSD License.
       
     5 http://yuilibrary.com/license/
       
     6 */
       
     7 
       
     8 YUI.add('yql-nodejs', function (Y, NAME) {
       
     9 
       
    10 /**
       
    11 * NodeJS plugin for YQL to use native request to make requests instead of JSONP.
       
    12 * Not required by the user, it's conditionally loaded and should "just work".
       
    13 * @module yql
       
    14 * @submodule yql-nodejs
       
    15 */
       
    16 
       
    17 var request = require('request');
       
    18 
       
    19 //Over writes Y.YQLRequest._send to use request instead of JSONP
       
    20 Y.YQLRequest.prototype._send = function (url, o) {
       
    21     request(url, {
       
    22         method: 'GET',
       
    23         timeout: o.timeout || (30 * 1000)
       
    24     }, function(err, res) {
       
    25         if (err) {
       
    26             //The signature that YQL requires
       
    27             o.on.success({
       
    28                 error: err
       
    29             });
       
    30         } else {
       
    31             o.on.success(JSON.parse(res.body));
       
    32         }
       
    33     });
       
    34 };
       
    35 
       
    36 
       
    37 }, '3.10.3');