8
Xonuss
6y

Heya. Now I feel like a fool for asking and it has been bothering me for a while.

I want to get into native application development, but I simply cannot wrap my head around how to connect a backend to the frontend.

I have been doing web development, I understand the concept of endpoints and I am able to do http requests for web apis etc. But when it comes to creating it in some native application, I have no clue what to do.

Does anyone have a good post or video that describes these connections, as for some reason I cannot seem to find any.

Hope it's understandable,
Cheers

Comments
  • 1
    What is the actual problem you run into?

    This is only as difficult as you make it

    If you understand requests and endpoints you are good to go
  • 1
    As you know web development you already have 80% knowledge of how things work. Most of the time you are going to use APIs for CRUD operations(mobile applications are thin client). See a bigger picture like this on web you develop frontend as well as backend logic on a same level where in mobile application your entire frontend logic will be at client and your backend logic at server. To connect both you are going to use apis which will have certain rules for CRUD operations(most probably REST apis or Micro services or even web sockets). If you already know about apis then I would say start with native development don't worry about connection part as it can be covered very easily(obviously you are going to use libraries for performing this tasks). If not then I would say do more research about api architecture and how operations take place(not in terms of coding but some theory).
  • 1
    You already have the knowledge, you just need to connect the strings

    You just call your API the same way that you call it with XMLHttpRequest (also known as Ajax in jQuery), the only difference is that it's probably being called something else depending on you're choice of programming language and choice of package
  • 1
    Yeah, for a RESTful API Backend you just open up endpoint lets say [POST,GET,PUT,DELETE]/user, that would cover a simple CRUD. Communication with REST is now most often done using JSONs so something like {"email":"root@devrant.com", "name"...} You would construct on Frontend and JSONify it and then using wither a library or ajax you call some equivalent of response = http.post(http://myserver.com/user, myJson);

    And bam, you just connected your user creation to your Backend code. Same can go for all other Http methods. Sometimes instead of json its enough to use url params, like your paging details can be in the url directly and such... After everything goes well on BE it will give you a response, ideally with a 2xx code and if you need it, some data too, also in a JSON format so you can parse it into a javascript map/dict and use it to update the interface properly, or display some message to the user.

    In short, thats the basics and work for 70% of the cases easily
Add Comment