Skip to content

Simple API with some endpoints for the CRUD-Frontend project.

Notifications You must be signed in to change notification settings

AleixFerreCP/CRUD-API

Repository files navigation

CRUD-API

Simple API with some endpoints to serve the Angular frontend

Endpoints

GET "/contacts"

It retrieves all the contacts from the database.

No body required

Response

It will always return a 200 code with a list of the contacts' info.

GET "/contacts/:id"

It retrieves a contact from the database with a certain id.

No body required

Response

It will return a 200 code with the contact info.

If the contact does not exist it will return a 404 code.

POST "/contacts"

Create a new contact.

Add all the new contact info in the body, like:

{
  "name": "New Name",
  "phone": "600582123",
  "notes": "Some notes here",
  "secphone": "953428583",
  "email": "[email protected]"
}

Response

It will always return a 201. Any 5** error is due to the database capacity.

PUT "/contacts/:id"

Edit existing contacts.

Pass the id of the existing contact into the URL parameters.

The body sould contain all the updated contact content like this:

{
  "name": "New Name",
  "phone": "600582123",
  "notes": "Some notes here",
  "secphone": "953428583",
  "email": "[email protected]"
}

Response

It will return a 200 code if the id exists.

Else a 404 code is returned.

DELETE "/contacts/:id"

Delete a certain contact from the contacts list.

Pass the id of the existing contact into the URL parameters.

Response

It will return a 200 code if the id exists.

Else a 404 code is returned.

About

Simple API with some endpoints for the CRUD-Frontend project.

Resources

Stars

Watchers

Forks