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 !