I am working on an App and I am trying to do xmlhttp request in nodejs and express but my responseXML is not working and it returns nothing.. Here is my code:-
var XMLHttpRequest=require("xmlhttprequest").XMLHttpRequest;
var xml2js=require("xml2js");
var xhr=new XMLHttpRequest();
xhr.onreadystatechange=function(){
console.log("State:"+this.readyState);
if(this.readyState==4){
var result=this.responseXML;
console.log(result);
}
};
xhr.open("GET","http://isbndb.com/api/books.xml?access_key=QMMEUNJB&results=prices&index1=isbn&value1=0061031321");
xhr.setRequestHeader('Content-type', 'text/xml');
xhr.send();
And the output is:-
Output:-
State:1
State:1
State:2
State:3
State:4
It returns a blank line after State:4