#Nater
1 messages · Page 1 of 1 (latest)
Can you share the code you're using?
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:
Any particular reason why you're using the XMLHttpRequest API? It's pretty antiquated at this point
We've a Node.js lib: https://github.com/stripe/stripe-node
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?
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
I'd recommend reading this if you're set on using XMLHttpRequest: https://javascript.info/xmlhttprequest
You need to add listeners (like load) for handling your request has resolved
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
fetch is a more modern browser API for making network requests: https://javascript.info/fetch
Yeah, because you haven't configured an event listener for when it resolves
I can work through fetch if thats recommended
AFAIK, XMLHttpRequest doesn't support Promises (like you've coded)
fetch is a much simpler API
yeah, I haven't configured a listener...I didn't know it was necessary 😄 I'll work on fetch
simple is good
thanks ynnoj
Sure, let us know how you get on
will do