I am trying to parse the rate limit headers, i.e I have some request to some helix endpoint and access the headers on data.headers after I issued a request with my token, however I can’t grab the data from the header, which I need.
My response looks like this
{ headers:
{ ‘Client-ID’: ‘myclientid’,
Accept: ‘application/vnd.twitchtv.v5+json’,
Authorization: ‘Bearer myAccessToken’ } }
{ connection: ‘close’,
‘content-length’: ‘2273’,
‘access-control-allow-origin’: ‘*’,
‘cache-control’: ‘no-cache, no-store, must-revalidate, private’,
‘content-type’: ‘application/json; charset=utf-8’,
expires: ‘0’,
pragma: ‘no-cache’,
‘ratelimit-limit’: ‘800’,
‘ratelimit-remaining’: ‘799’,
‘ratelimit-reset’: ‘1590589847’,
server: ‘envoy’,
‘timing-allow-origin’: ‘https://www.twitch.tv’,
‘twitch-trace-id’: ‘ae30829b90816a8a489677d99d760bf3’,
‘x-ctxlog-logid’: ‘1-5ece7996-3522785349169528b35ba92c’,
date: ‘Wed, 27 May 2020 14:30:46 GMT’,
‘x-served-by’: ‘cache-sea4464-SEA, cache-cph20620-CPH’,
‘x-cache’: ‘MISS, MISS’,
‘x-cache-hits’: ‘0, 0’,
‘x-timer’: ‘S1590589846.968417,VS0,VS0,VE212’,
vary: ‘Accept-Encoding’,
‘strict-transport-security’: ‘max-age=300’ }
How do I parse this object and get the strings:
‘ratelimit-limit’: ‘800’,
‘ratelimit-remaining’: ‘799’,
‘ratelimit-reset’: ‘1590589847’