help with first backend project
im gonna be doing my first backend project, im already familar with frontend, and i just finished a 4 hour mysql tutorial
the project that i picked is called "personal blogging platform api", and these are the tasks that im given:-
Return a list of articles. You can add filters such as publishing date, or tags.
Return a single article, specified by the ID of the article.
Create a new article to be published.
Delete a single article, specified by the ID.
Update a single article, again, you’d specify the article using its ID.
my question was that: isnt this like 99% a frontend project, where even is the backend part in these tasks.
28 Replies
"api" implies there's no frontend
you return json based on data fetched from a database, filtered by input from the frontend
the code that receives the request from the frontend, gets data from the database, reformats it, and sends it back to the frontend is the backend code
None of that can be done on the front end, so I don't understand your question.
The browser can't create a new article or get a list of them. That's literally what the back end does
For example, to return a single article the back end needs to receive a request for the specific article. Potentially verify that the request is valid (the user has permission to do that). It then needs to search the DB for the data, potentially read the file system for the pre-rendered file, and send it back to the front end.
ohh
btw what does "returning" mean here?
is it the same as loading
so any project that includes api is a fullstack project?
The front end asked for a resource. The back end must give it to them.
return as in a function return, where it sends the reponse to the HTTP request for the data
All REST APIs are, yesohh
But "API" as a term can be almost anything. For example,
fetch has an API—it's how you use fetch.
document.querySelector() is part of the Document API.
Using canvas to animate things uses the Canvas API
"API" is simply a term that means "this is how you interface with THING"is the dictionary, weather apps i made using dictionary api, and free weather api also a backend project?
Most back ends these days use a REST API, where you send an HTTP request to the back end to do something and it returns the data requested
oh
Depends: did you code anything on the back end? If so, yes. if not, no :p
"Back end" means "it runs on the server". Your HTML and CSS are front end, since it runs in the browser, also called a client.
this was the js code of the weather api app
can u tell from this
That uses browser APIs, so it's front end code
ohh
As far as JS goes: back end is Nodejs. Front end is browser
oh yeahh
You interface with a backend, since you're calling the
weatherapi.com REST API endpoint
But you didn't do any of the coding on that REST API, so it's nota back end projectyeah
i was wondering how should i go about doing this project, im totally new to backend stuff
i spent the past month practicing mysql
It's really not much different than the front end code you write, you just use the Node APIs instead of Browser APIs, but the core JS language is the same
oh
Several web APIs are still available in Nodejs, like
fetch (did you know that fetch is a browser API and not part of the JavaScript langauge?)oh wow
i think i read it in javascript.info
Back end code has more power, though, as you can access the local file system, get info about the local OS, even spawn local programs
oh
As an example, if you generate static HTML files for your articles, those would be saved to the local file system, so you'll need to use the
fs module. Though usually that's taken care of by your reverse proxy (nginx or Caddy). Nodejs should not be used to do that in productionoh
also i was wondering, while learning backend, should i use the same routine i used to learn frontend, spend 99% of the time building projects one after the other?
yup
ohk
tutorials are valuable as a start, making things is how you actually learn and remember