#Nater

1 messages · Page 1 of 1 (latest)

warped oreBOT
acoustic zenith
#

Can you share the code you're using?

finite musk
#

create a function:

#

function myHTTPRequest(method, url, callback, body) {
const xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
callback(JSON.parse(this.response));
}
};
xhttp.open(method, url, true);
xhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded')
// bearer
xhttp.send(body);
}

#

create the request:

acoustic zenith
#

Any particular reason why you're using the XMLHttpRequest API? It's pretty antiquated at this point

finite musk
#

that's really all I have gotten to work

#

I can work on trying that... Can I just load that into the headers of my site then?

#

is there a way to test it with Console outside of adding it to the site?

acoustic zenith
#

Is this in client-side JavaScript?

#

stripe-node won't work there

finite musk
#

overall what I'm trying to do is create a simple form that will take info from the customer and create a price and payment link

acoustic zenith
#

You need to add listeners (like load) for handling your request has resolved

finite musk
#

ok, I'm not set on it, its just the thing I've been able to make work from the chrome console

#

the side that won't work is the response

acoustic zenith
finite musk
#

so it seems like working on getting the library to load for a client

#

ok

acoustic zenith
finite musk
#

I can work through fetch if thats recommended

acoustic zenith
#

AFAIK, XMLHttpRequest doesn't support Promises (like you've coded)

#

fetch is a much simpler API

finite musk
#

yeah, I haven't configured a listener...I didn't know it was necessary 😄 I'll work on fetch

#

simple is good

#

thanks ynnoj

acoustic zenith
#

Sure, let us know how you get on

finite musk
#

will do