Well, this is a big debate and people have their preferences. Yes, it does blend the two but that's the way modern frameworks are going. We've been blending frontend//backend more and more for years as the tools gets better and better. My personal take according to the focus of the major frameworks is this is going to be the future!
Behold, the js frameworks slowly morph back into a PHP/Perl/ColdFusion/etc architecture. The more things change... =) Thanks for covering this, James. Since you asked, I prefer fetch, though I still sometimes am even known to crank out a new XMLHttpRequest...
"Yes, the old ways are still best at Los Pollos Hermanos". ―Excerpt from the Los Pollos Hermanos TV commercial (Breaking Bad). Old becomes the new new. Tech has always been going back full circle.
@@maelstrom57 An engineer is supposed to be versatile. I go from React Native, ReactJS, Laravel, Django, NodeJS to good old Bash depending on what is supposed to get done.
Sveltekit does this automatically, when you fetch an internal api endpoint server side, it automatically calls the endpoint handler instead of actually making the http request !
Really like the way you create these to the point web "snip-it's". Your like laser focus and spot on with info new to my vocabulary coming from a network, security and "OS system" API background. It's taken me a while to swallow what a "web" API is. MAJOR paradigm shift.
Two questions: - 1/ Is there a way to organize this type of backend code in a more maintainable way? I think about Clean Architecture or something like that. - 2/ If I understand well. The server code is running on netlify servers, as a type of node server. But your database is hosted by Xata, on another server. So, there will be a request from the code running on netlify and Xata instance ? Am I right ?
1. I think the main thing would be to create server side functions that can be use from anywhere on the server. So, I'd probably move my coupons code to a helper function in a utils directly and just call it. 2. Yes, the server code runs on Netlify. Then the Xata DB is hosted on their server. So, the server does make a DB request to the DB Server
@@JamesQQuick Hi James. Thanks to your reply. For the second point, do we have some metrics to compare performance or security between our code and the database? Could we compare a standard JS fetch method form our code, and the Xata client code? I wonder if Xata use another method than fetch, and what could it be (sockets?) ?
So true much easier to be able to manage backend end code and consume on the frontend in the same file, especially with Astro. One thing that limits this behavior with Astro it's when you're using island components. For example with a click event you want to call the API. If you declare your function in the Astro file and want to pass that function as props into your React component (for example), you can't. You will still have to use a fetch method in your react component creating an api endpoint. The good thing of having an endpoint in another file is that you can reuse it in different pages, no need to re-write the function in every Astro file that need it. Anyway, totally agree that in most cases no need to have to fetch, which is pretty cool!!!
Everything old is new again :) This feels SO much like the ye olde PHP that we were writing 15-20 years ago. Feels _exactly_ like the views we were writing in some ancient version of Zend framework
Maybe I'm the odd one out but I don't use frameworks for my apps (engineering materials and price calculation). To get data from the server Fetch and a few lines of PHP code works just fine for me...I convert static non-confidential data from Excel to a JS object that's included in the build...I'm a great fan of KISS ;-)
@@JamesQQuick Yes I do - old version 5.6. I like it because it's so simple, very well documented and I'm a great fan of KISS and good documentation. It is also cheap to host... My basic use is to serve semi-static pages with a few modifications and static data when required. Most of it is a single PHP script which is included by the handler script. Total lines of script: about 100. And yeah...I admit I'm lazy. Never change a winning team... But hey...that definitely does not mean you are wrong. It is just what I'm used to since 1974... Keep up the good works...I enjoy your videos even if I don't always agree.
Well, this doesn't imply making fetch requests on the server. It implies...just run your logic on the server and remove (mostly) the need to make fetch requests to your backend.
Not sure what fetch not solving for 3rd world country projects.... even works with graphql... maybe better video will be: write agnostic http client function, so I can change fetch on the fly.... L in the SOLID principle :)
The video was mostly about accessing ressources from the server directly instead of creating API endpoints. For external resources, you might need to still use fetch or other data fetching libraries 🤷🏻♂️ I stand to be corrected
Absolutely true. I even mentioned that in the video that it doesn't replace fetch completely. BUT I think we need it a lot less and should encourage developers to run code on the server vs making requests to their own backend when possible. Thanks for sharing though. Always looking for feedback on whether or not title/thumbnails still hold true when seeing the content!@@_techbk
I think those who said this clickbait. Don’t understand there are 2 servers involved here. As a backend person I think essentially you are moving code from the backend server to the (frontend) server, right?
Actually in this case, I don't have two different servers. It's just one server in AStro which handles both frontend and backend. But yes, moving fetch requests out of the frontend and moving to running logic on the server instead.@@aribasiebel
Doesn't this cause close coupling where the frontend is really dependent on backend
Well, this is a big debate and people have their preferences. Yes, it does blend the two but that's the way modern frameworks are going. We've been blending frontend//backend more and more for years as the tools gets better and better. My personal take according to the focus of the major frameworks is this is going to be the future!
Behold, the js frameworks slowly morph back into a PHP/Perl/ColdFusion/etc architecture. The more things change... =) Thanks for covering this, James. Since you asked, I prefer fetch, though I still sometimes am even known to crank out a new XMLHttpRequest...
Wouldn't be surprised if you're still coding in Perl.
"Yes, the old ways are still best at Los Pollos Hermanos". ―Excerpt from the Los Pollos Hermanos TV commercial (Breaking Bad).
Old becomes the new new. Tech has always been going back full circle.
@@maelstrom57 An engineer is supposed to be versatile. I go from React Native, ReactJS, Laravel, Django, NodeJS to good old Bash depending on what is supposed to get done.
lol yeah that’s the big thought. It is funny but I do feel like the developer experience around all of that has gotten better and better
Me? Why do you think that?
0:25 I always use fetch, you can easily wrap it around a function or class to suit your needs and you do not need to install a library for it
Love it! I typically use fetch too1
Sveltekit does this automatically, when you fetch an internal api endpoint server side, it automatically calls the endpoint handler instead of actually making the http request !
Yeahh! That's such a nice feature. Really cool to have that taken care of behind the scenes!
Hey james, what courses do you recommend for node/express?
Really like the way you create these to the point web "snip-it's". Your like laser focus and spot on with info new to my vocabulary coming from a network, security and "OS system" API background. It's taken me a while to swallow what a "web" API is. MAJOR paradigm shift.
Svelte does this automatically... converts server fetch to a procedure if to same backend.
Yep! Super cool feature!
Title is misleading… Clickbait.
Would love some feedback on your thoughts here!
Two questions:
- 1/ Is there a way to organize this type of backend code in a more maintainable way? I think about Clean Architecture or something like that.
- 2/ If I understand well. The server code is running on netlify servers, as a type of node server. But your database is hosted by Xata, on another server. So, there will be a request from the code running on netlify and Xata instance ? Am I right ?
1. I think the main thing would be to create server side functions that can be use from anywhere on the server. So, I'd probably move my coupons code to a helper function in a utils directly and just call it.
2. Yes, the server code runs on Netlify. Then the Xata DB is hosted on their server. So, the server does make a DB request to the DB Server
@@JamesQQuick Hi James. Thanks to your reply. For the second point, do we have some metrics to compare performance or security between our code and the database? Could we compare a standard JS fetch method form our code, and the Xata client code? I wonder if Xata use another method than fetch, and what could it be (sockets?) ?
Hola James, ¿tu curso de Astro tiene subtítulos en español? Saludos...
Hi does anyone know which theme James is using in VSCode?
I'm using my theme, James Q Quick - marketplace.visualstudio.com/items?itemName=jamesqquick.james-q-quick-vs-code-theme
you are awesome can you tell which font-family and theme you are using or you can paste setting.json in vscode
]
James Q Quick theme (it's mine ) and Cascadia Code font!
So true much easier to be able to manage backend end code and consume on the frontend in the same file, especially with Astro. One thing that limits this behavior with Astro it's when you're using island components. For example with a click event you want to call the API. If you declare your function in the Astro file and want to pass that function as props into your React component (for example), you can't. You will still have to use a fetch method in your react component creating an api endpoint. The good thing of having an endpoint in another file is that you can reuse it in different pages, no need to re-write the function in every Astro file that need it. Anyway, totally agree that in most cases no need to have to fetch, which is pretty cool!!!
Yep, there are definitely still use cases for making API requests from the front, just a lot less than there used to be lol
Is this mean fetch db directly from frontend?
No. It means run more code on the server to start instead of making fetch requests from the frontend to the backend.
Is the coupon invalid? ):
All the free coupons have now been used. You can still use the student discount code though
Hello PHP my old friend.
Everything old is new again :)
This feels SO much like the ye olde PHP that we were writing 15-20 years ago. Feels _exactly_ like the views we were writing in some ancient version of Zend framework
Maybe I'm the odd one out but I don't use frameworks for my apps (engineering materials and price calculation). To get data from the server Fetch and a few lines of PHP code works just fine for me...I convert static non-confidential data from Excel to a JS object that's included in the build...I'm a great fan of KISS ;-)
Whatever works! So you're using PHP for your backend?
@@JamesQQuick Yes I do - old version 5.6.
I like it because it's so simple, very well documented and I'm a great fan of KISS and good documentation. It is also cheap to host...
My basic use is to serve semi-static pages with a few modifications and static data when required. Most of it is a single PHP script which is included by the handler script. Total lines of script: about 100.
And yeah...I admit I'm lazy. Never change a winning team...
But hey...that definitely does not mean you are wrong. It is just what I'm used to since 1974...
Keep up the good works...I enjoy your videos even if I don't always agree.
As long as it's working for you. That's all that matters!@@montebont
Reaching for data from the source, instead of adding abstraction.
Title edit : ""Do fetch from the server side"
Well, this doesn't imply making fetch requests on the server. It implies...just run your logic on the server and remove (mostly) the need to make fetch requests to your backend.
I think it means move the rest api logic to the (front end) server. Because browser client is no longer talking to the API backend server directly.
Missed opportunity for "Stop trying to make fetch happen"
Hahaha how did I not think of this?!?!?!?!
Extremely high quality content
Thank you so much!
Great great content! Thanks for the coupon code!
Absolutely!
Thanks
video title is misleading af
and you know exactly why
do better
Thanks for the coupon.
Enjoy :)
Not sure what fetch not solving for 3rd world country projects.... even works with graphql... maybe better video will be: write agnostic http client function, so I can change fetch on the fly.... L in the SOLID principle :)
James I really appreciate the early bird discount code, super kind of you!
Absolutely! Hope you enjoy the course!
Hahaaha
What a clickbait lol
Would love some feedback. What would you change?
The video was mostly about accessing ressources from the server directly instead of creating API endpoints.
For external resources, you might need to still use fetch or other data fetching libraries 🤷🏻♂️
I stand to be corrected
Absolutely true. I even mentioned that in the video that it doesn't replace fetch completely. BUT I think we need it a lot less and should encourage developers to run code on the server vs making requests to their own backend when possible. Thanks for sharing though. Always looking for feedback on whether or not title/thumbnails still hold true when seeing the content!@@_techbk
I think those who said this clickbait. Don’t understand there are 2 servers involved here. As a backend person I think essentially you are moving code from the backend server to the (frontend) server, right?
Actually in this case, I don't have two different servers. It's just one server in AStro which handles both frontend and backend. But yes, moving fetch requests out of the frontend and moving to running logic on the server instead.@@aribasiebel
Fetch
Nice. Have you used a iOS before? Just still prefer fetch?
@@JamesQQuick my web apps have huge h1 satating "only for Android"
@@JamesQQuick im a beginner.. will pay attention from now on :))