skip to Main Content

I have created an API in symfony to consume it in React. How can I add more data to the API from React?

I have only managed to add data through phpMyAdmin. I don’t know if there is a way to create a form in react to be able to update the data from there, from the web deployed. The entire project is local.

2

Answers


  1. You can Create a crud and add the data from there

    Login or Signup to reply.
  2. You can create a controller that persists the info sent to it by the front. Example:

    $email = $request->query->get("email");
    $user->setEmail($email);
    $entityManager->persist($user);
    $entityManager->flush();
    

    You can send the info to controller through the PATCH method. Yo can make a API with this method

    GET
    /api/users
    Retrieves the collection of Users resources.
    POST
    /api/user
    Creates a User resource.
    GET
    /api/users/{id}
    Retrieves a User resource.
    PUT
    /api/users/{id}
    Replaces the User resource.
    DELETE
    /api/users/{id}
    Removes the User resource.
    PATCH
    /api/users/{id}
    Updates the User resource.
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search