Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

167
Views
"This" not returning asked value

Im a beginner in Javascript, and I have the following problem ... can someone tell me what I'm doing wrong ? Thanks !

So, go on Instagram, fill the following code in the console:

var open = window.XMLHttpRequest.prototype.open,
    onReadyStateChange;

function openReplacement(method, url, async, user, password) {
    if (url.match(/https:\/\/i\.instagram\.com\/api\/v1\/feed\/user\/[0-9]{1,16}\/story\//g)) {
        console.log(url)
        console.log(this)
        console.log(this.response)
    }
    return open.apply(this, arguments);
}

window.XMLHttpRequest.prototype.open = openReplacement;

So, when I do this and go on a profile, it is supposed to read and print the api response to the get the story data, and it prints the following thing for the console.log(this):

XMLHttpRequest:
    listeners: {load: Array, error: Array, timeout: Array}
    onabort: null
    onerror: function(t)
    onload: function()
    onloadend: null
    onloadstart: null
    onprogress: null
    onreadystatechange: null
    ontimeout: function()
    readyState: 4
    response: "{\"broadcast\":null,\"reel\":{\"id\":…"
    responseText: "{\"broadcast\":null,\"reel\":{\"id\":…"
    responseType: ""
    responseURL: "https://i.instagram.com/api/v1/feed/user/AN_ID/story/"
    responseXML: null
    status: 200
    statusText: ""
    timeout: 10000
    upload: XMLHttpRequestUpload {onloadstart: null, onprogress: null, onabort: null, onerror: null, onload: null, …}
    withCredentials: true

But when the following line comes console.log(this.response), an empty line is printed. And it does this with every values printed in the this upper. I tried to console.log(Object.keys(this)), but same, an empty line is printed ...

If I do this.test = "test there" and do console.log(this.test), "test there" is well printed.

What am I doing wrong ??? Why isn't it returning me the response value from the this ? Thanks for your help !

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!