1
4 Comments

How do you send data from Frontend to Backend?

This is probably a stupid question but I needed to ask this because it's been a long time since I developed my last web app with raw PHP. So basically I'm was a raw PHP developer. So I know raw PHP, MySQL, HTML, CSS and some Javascript. I'm starting again and I decided to make something simple with CRUD operations. I looked at Svelte/Sapper and it looks interesting. So how do I send form data to a backend PHP API and how do I fetch data from that PHP API? Thanks in advance.

posted to Icon for group Developers
Developers
on July 12, 2020
  1. 1

    You basically created CRUD endpoints that render server responses based on the URL and HTTP method (so post for adding data, patch for changing data, delete for removing data etc.) — read about REST and architecture of that 👍🏻

  2. 2

    This comment was deleted 4 years ago.

    1. 2

      I have no words for it because I'm unable to debug it, when I get and error it takes 1-4 hours to fix it.

      Just to make sure you are aware, in JavaScript front you can add

      debugger;
      

      On a line in your code to add a breakpoint. Much like pdb in python. If you are trying to debug a front end app with inspector open it will pause the code getting executed on this line
      You can then find out what all the different variable values are and step through you code etc.

      1. 1

        This comment was deleted 4 years ago.

        1. 1

          Oh I feel you, I much prefer Python to Javascript when I can. I find a large number of JS packages etc hard to read due to odd code styles etc.

          Just as a note on JS linters, I pretty much always install eslint-config-airbnb for any project I start with JS. It uses ESLint to enforce the Airbnb JavaScript Style Guide which I find sane.
          It doesn't make other peoples code easier to read but I find it keeps my code easy enough to pick back up when I need to.

    2. 1

      Thank you. You are right, I was a little confused. I thought Sapper would not be able to handle backend. I guess I have to learn it more thoroughly.

Trending on Indie Hackers
I built a text-to-video AI in 30 days. User Avatar 52 comments I built something that helps founders turn user clicks into real change 🌱✨ User Avatar 49 comments What 300 Builders Taught Us at BTS About the Future of App Building User Avatar 33 comments From a personal problem to a $1K MRR SaaS tool User Avatar 30 comments You don't need to write the same thing again User Avatar 29 comments I built an Image-to-3D SaaS using Tencent's Hunyuan 3D AI User Avatar 25 comments