Endpoint to create note

We’ll have to create an endpoint for creating a new note. We’ll use POST method as we’ll have to send data of note to the Fabloq backend.

  1. Go to workspace page and select “new endpoint”.
  2. Name the endpoint as “createNotes” and url as “/notes/create/”.
  3. We’ll use post method here as we want to send data.
  4. Select “save” to create your endpoint.
  5. To create a new note in the database we’ll use a “database create” block.
  6. Add variable name as “note”.
  7. Drag and drop a “database create” block and select “note” table in table name.
  8. All the request data is stored in the data variable. To store the request data in respective fields of note table we’ll extract the fields from data variable using dot operator.
  9. In the name field use doublr curly brackets to access the variable {{ }} and dot . Operator to access appropriate data. So enter {{data.name}} in the name fields.
  10. Similarly, enter {{data.body}} in the body field.
  11. And save the block.
  12. Drag and drop a response block and select 200 status code to send a success response and save the response block.
  13. Deploy the project

# Test it out

  1. Since we’ll use react as our frontend, clone the github repo and run npm install in the root of cloned react project.
  2. Change the "projectName" variable to your Fabloq project name. Start by typing npm start.
  3. Once the project is launched in browser, click on “add new note” to test your project.
  4. Next we’ll create endpoint to list all the notes that we create....

# Next steps

Now lets make an endpoint to get list of all notes. See Build endpoint to get list of all notes