How to use XMLHttpRequest in ionic


#1

Actually I tired to send headers but am not able to do

var data = new FormData();

data.append("email", "flycodersonesignal@gmail.com");

var xhr = new XMLHttpRequest();

xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {

if (this.readyState === 4) {

console.log(this.responseText);

}

});

xhr.open("POST", "http://mydomain.ca/helpify/api/password/create");

xhr.setRequestHeader("Content-Type", "application/json");

xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");

xhr.send(data);

}

Please help me out
thanks


#2

Why?

Angular has the HttpClient which does this for you.


#3

Thanks for your response
Actually i want to try send header but nothing happen


am try to implement this rest api
please help me how can i do that.
Thanks in advance


#4

If I get time over the weekend to knock together an example http post I will


#5

Thanks @Judgewest2000


#6

@Judgewest2000 awating for your response please can you give me a sample code of XMLHttpRequest for ionic
Thanks


#7

Hi,

I’ve managed to get this knocked up this morning…

It shows you the headers in a POST…


#8

Thanks for giving me your valuable time .please let me try


#9

Really you are a rock. Thanks for save my time its working fine for me