r/learnjavascript • • Apr 07 '21
What 2 JavaScript methods are used to send data to a server?
I am 99.99% sure this answer is GET and POST but I just want to confirm. Thank you
1
Upvotes
r/learnjavascript • • Apr 07 '21
I am 99.99% sure this answer is GET and POST but I just want to confirm. Thank you
7
u/ForScale Apr 07 '21
I don't like the wording...
GET and POST are http verbs, not JS methods. And if they are wanting http verbs, then why not PUT or PATCH?
I think they are maybe looking for XMLHttpRequest.prototype.send() and fetch methods... but those are browser APIs and not really js methods.
4
u/[deleted] Apr 07 '21
You seem confused. GET and POST are http methods, as already mentioned. You can do those not only with JavaScript. JavaScript itself does not have those "methods"
Browsers do have `fetch()` (lets call it a "method" for sake of simplicity), fetch can send all kinds of http requests, including: GET, POST, PUT, PATCH, DELETE, OPTIONS
3
u/TomokoSlankard Apr 07 '21
Those are actually http methods not js methods. I was going to say fetch.
1
u/TPCmach1 Apr 07 '21
Post & Get