Jump to content

How do developers send/request/receive data between front-end and back-end?

Go to solution Solved by igormp,

You use HTTP request, mostly GET (to retrieve data) and POST (to upload/modify stuff) (there are other verbs that are better suited to deletion/creation/modify, but let's simplify stuff here). With get requests you usually just say which content you want through query parameters, just as: example.com/?userName=DefinitelyRus&postCount=1

 

With POST requests, you also throw in some data in the body to do some processing on the backend, such as some json data that you can read on your backend and know what do to with it.

 

Mozilla has nice documentation on how everything works: https://developer.mozilla.org/en-US/docs/Web/HTTP

I'm a novice (but fairly experienced) back-end developer and I've thought of working with people in the front-end to make a fully featured program. However, this has always been an uncharted territory for me. I'm aware of some ways to transit data between languages, like using JSONs or Databases, but it's not practical to use those for on-request type of tasks. (e.g. retrieve X data but said data needs to be processed only upon request) I've also heard of things like HTTP requests which sounds like the answer to my question here but I have very limited knowledge when it comes to networks - I don't even know why "192.168.X.X" is used the way it is! 😄

 

Anyway, I suppose what I'm really asking here is how do front-end apps interact with back-end? And what should I look into to expand my knowledge about this?

"USB 3.2 Gen 2x2"

Link to post
Share on other sites

You use HTTP request, mostly GET (to retrieve data) and POST (to upload/modify stuff) (there are other verbs that are better suited to deletion/creation/modify, but let's simplify stuff here). With get requests you usually just say which content you want through query parameters, just as: example.com/?userName=DefinitelyRus&postCount=1

 

With POST requests, you also throw in some data in the body to do some processing on the backend, such as some json data that you can read on your backend and know what do to with it.

 

Mozilla has nice documentation on how everything works: https://developer.mozilla.org/en-US/docs/Web/HTTP

FX6300 @ 4.2GHz | Gigabyte GA-78LMT-USB3 R2 | Hyper 212x | 3x 8GB + 1x 4GB @ 1600MHz | Gigabyte 2060 Super | Corsair CX650M | LG 43UK6520PSA
ASUS X550LN | i5 4210u | 12GB
Lenovo N23 Yoga

Link to post
Share on other sites

2 hours ago, DefinitelyRus said:

Anyway, I suppose what I'm really asking here is how do front-end apps interact with back-end? And what should I look into to expand my knowledge about this?

Where I work, all of our apps (Android, iOS, macOS, web, Windows, ...) communicate with the server the same way. REST API over HTTP(S), exchanging JSON.

 

If a client needs information about a specific user, it'll perform a GET request on e.g. /users/<userUuid>. If it needs to create a new user it'll POST to that same endpoint. And if it needs to update a user it'll first get the user, modify it, then do a PUT request.

 

So stuff to look into would be https://restfulapi.net/ and also e.g. libraries for your client(s) and server that can transform JSON into objects (e.g. Gson, Jackson, Mosh for Java and many others for other languages)

Remember to either quote or @mention others, so they are notified of your reply

Link to post
Share on other sites

4 hours ago, igormp said:

You use HTTP request, mostly GET (to retrieve data) and POST (to upload/modify stuff) (there are other verbs that are better suited to deletion/creation/modify, but let's simplify stuff here). With get requests you usually just say which content you want through query parameters, just as: example.com/?userName=DefinitelyRus&postCount=1

So, if I understood this correctly, it's actually not that much different from setters and getters, of course with plenty of differences due to different purposes. I'll definitely keep looking into it, many thanks. 😄 

"USB 3.2 Gen 2x2"

Link to post
Share on other sites

1 hour ago, Eigenvektor said:

Where I work, all of our apps (Android, iOS, macOS, web, Windows, ...) communicate with the server the same way. REST API over HTTP(S), exchanging JSON.

...

So stuff to look into would be https://restfulapi.net/ and also e.g. libraries for your client(s) and server that can transform JSON into objects (e.g. Gson, Jackson, Mosh for Java and many others for other languages)

I heard REST API thrown around in discussions before, I never knew it's actually related to this. I'll give it a try on my next projects, cheers. 😄 

"USB 3.2 Gen 2x2"

Link to post
Share on other sites

17 hours ago, Sakuriru said:

This is an example

No no, it's very different.

 

To give a more comprehensive answer recall the OSI layers of the networking. What we're talking about here is actually built on TCP, but this isn't the... [Truncated]

That's a boat load of information alright! 😄 Admittedly, there are a few parts I don't quite understand, like the part about TCP and it being stateless. Nevertheless, it should be enough to get me familiarized with that to look for. Many thanks!

"USB 3.2 Gen 2x2"

Link to post
Share on other sites

7 hours ago, DefinitelyRus said:

That's a boat load of information alright! 😄 Admittedly, there are a few parts I don't quite understand, like the part about TCP and it being stateless. Nevertheless, it should be enough to get me familiarized with that to look for. Many thanks!

TCP or UDP for example are protocols. In very very simplified analogy it's the way the message is transported and handle. Like going from point a to point b you can walk, take a car or take a bus although your goal is the same but by walk it's longer and you control the direction, by bus you have predefine multiple stop, by car it's faster but you are also limited by roads. Yourself walking or inside the bus you are the data being transported (your json, raw bytes...).

Link to post
Share on other sites

On 2/22/2022 at 3:54 AM, DefinitelyRus said:

I'm a novice (but fairly experienced) back-end developer

Is that some new oxymoron I'm not familiar with? 🤔

Jokes aside, what kind of experience as a back-end dev you've got?
 

Link to post
Share on other sites

On 2/24/2022 at 10:14 AM, Biohazard777 said:

Is that some new oxymoron I'm not familiar with? 🤔

Jokes aside, what kind of experience as a back-end dev you've got?
 

Hahaha you got me there. What I meant was I'm fairly experienced to the point that I can create medium-scale projects from scratch but still a novice in the grand scheme of back-end stuff.

 

I've worked on a couple of projects involving APIs and Databases. For instance, I used Discord JDA (Discord-Java API) alongside MySQL to handle tasks like keeping a detailed list of tasks which can be modified and retrieved through Discord bot commands - it was certainly one heck of an overkill high school project compared to other groups (we did it for fun).

 

Another project I'm currently working on is an easy-to-maintain framework for an adventure game, the purpose for which is to essentially create an API that provides the bare bones for a game. A friend of mine, who is still getting used to programming, will then use said API to create a playable game. This kind of brings me back to this discussion, because we have been thinking of expanding it to a JavaScript-based web game, and we needed a way to bridge the gap between Python and JS.

"USB 3.2 Gen 2x2"

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×