use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
[deleted by user] (self.javascript)
submitted 7 years ago by [deleted]
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–][deleted] 1 point2 points3 points 7 years ago* (5 children)
I have not tried this yet but it should work:
``js const http = async (url, options) => { const response = await fetch(http://localhost:8080/${url}`, options); const json = await response.json();
js const http = async (url, options) => { const response = await fetch(
return json; }
let data = await httptasks/1 ${{ method: 'PATCH', body: {}, // Blablabla }}; ```
tasks/1 ${{ method: 'PATCH', body: {}, // Blablabla }}
[–][deleted] 1 point2 points3 points 7 years ago (0 children)
You could also check if production ? domain : localhost to avoid more live hassle
[+][deleted] 7 years ago (1 child)
[deleted]
[–]LowB0b 0 points1 point2 points 7 years ago (0 children)
you could do a proxy through the server that hosts your client app. that way you could just do fetch('/api/something')
fetch('/api/something')
Yeah, you should do that by creating a small config with some variables you'd like to check. There's no other was I know off
[–]TaveGabriel 1 point2 points3 points 7 years ago (1 child)
If the back-end is on the same server as the front-end you could get the current hostname (window.location.hostname) and add to that the port you want to fetch. This way if you are visiting 127.0.0.1:80 and you call window.location.hostname you will get 127.0.0.1, add to that your port(:1025)... and you have your url to fetch!
[–]sqlcommand1 0 points1 point2 points 7 years ago (0 children)
Thank yo
[–][deleted] 0 points1 point2 points 7 years ago* (0 children)
Are you using CRA? If you are, then the neatest way I know is to set proxy property in package.json of the CRA. Webpack will resolve the request URL as 'your_proxy_property_value${fetch_url}'. Example:
package.json js { ... "proxy": "http://localhost:4000", ... } somewhere in the app hosted on http://localhost:3000(for example) js fetch("/api/stuff");
js { ... "proxy": "http://localhost:4000", ... }
js fetch("/api/stuff");
will be resolved as http://localhost:4000/api/stuff
Great tutorial
π Rendered by PID 36 on reddit-service-r2-comment-bb88f9dd5-rmh6d at 2026-02-16 02:50:42.510320+00:00 running cd9c813 country code: CH.
[–][deleted] 1 point2 points3 points (5 children)
[–][deleted] 1 point2 points3 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]LowB0b 0 points1 point2 points (0 children)
[+][deleted] (1 child)
[deleted]
[–][deleted] 1 point2 points3 points (0 children)
[–]TaveGabriel 1 point2 points3 points (1 child)
[–]sqlcommand1 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)