locked
response headers server script? RRS feed

  • Question

  • I'm trying to get headers from Twitter in my server script for Scheduler

    According to docs I can use get()

    http://msdn.microsoft.com/en-us/library/windowsazure/dn303373.aspx

    TypeError: Object [object Object] has no method 'get'

      limitTotal = response.get('X-FeatureRateLimit-Limit');
      limitRemaining = response.get('X-FeatureRateLimit-Remaining');
      limitReset = response.get('X-FeatureRateLimit-Reset');                    
      console.log('limit total:'+limitTotal+' limit remaining:'+limitRemaining)

    Thursday, July 18, 2013 3:09 AM

Answers

  • Hi,

    You say you make a request to Twitter, so you are not getting response object from the doc you have presented. This response object is related to express response in Custom API.

    You are likely making a request using var request = require('request') module. Documentation for it is available on https://github.com/mikeal/request.

    In the response object from request module it will likely be something like below (not tested):

    response.headers['X-FeatureRateLimit-Limit'];

    Rafal


    • Proposed as answer by Rafał Jońca Thursday, July 18, 2013 8:09 AM
    • Marked as answer by Forkoholic Thursday, July 18, 2013 1:57 PM
    Thursday, July 18, 2013 8:09 AM

All replies

  • Hi,

    You say you make a request to Twitter, so you are not getting response object from the doc you have presented. This response object is related to express response in Custom API.

    You are likely making a request using var request = require('request') module. Documentation for it is available on https://github.com/mikeal/request.

    In the response object from request module it will likely be something like below (not tested):

    response.headers['X-FeatureRateLimit-Limit'];

    Rafal


    • Proposed as answer by Rafał Jońca Thursday, July 18, 2013 8:09 AM
    • Marked as answer by Forkoholic Thursday, July 18, 2013 1:57 PM
    Thursday, July 18, 2013 8:09 AM
  • Twitter actually changed the keys names

     [x-rate-limit-limit] =>
        string(3) "180"
        [x-rate-limit-remaining] =>
        string(3) "179"
        [x-rate-limit-reset] =>
        string(10) "1374155227"

    and your approach works, thanks!

    Thursday, July 18, 2013 1:57 PM