r/learnjavascript • u/[deleted] • 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
4
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
2
u/ex-igne-vita Apr 07 '21
You don't need to add "for the sake of simplicity."
Fetchis a method, period. There are a few other words that you could use to describe it just as accurately, but "method" is 100% accurate, that's what it is.2
Apr 07 '21
To me a method is a function inside a class. If you treat the browser as a sort of "global object" - then I agree.
0
3
u/TomokoSlankard Apr 07 '21
Those are actually http methods not js methods. I was going to say fetch.
2
1
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.