One POST endpoint for both create and update

Hi there,

I am working on a project with weweb.io and xano. I want to use a product details page for both creating new product record and update project record.

To optimize the setup I want to use one POST endpoint for both create and update. In weweb I only need to configure one Xano request with field mappings.

On the POST /product endpoint I want to make project_id input nullable. In the function stack I want to add a condition to check if product_id provided.

If it is: I want to fetch the product record. Add a precondition that the product record must exist, and update it if that's the case

If it is not: I just create a new product record.

Questions I have:

  1. Is this setup feasible or does it break too much with the basic convention to have seperate endpoints for create and update ?

  2. Is my proposed setup secure enough?

7 replies