Introducci贸n a Node.js y Express
Node.js y Express
Entorno de trabajo
Variables de entorno
Rutas din谩micas
Body parser
Postman
CRUD
驴Que es una API Restful?
Solicitudes GET
Solicitudes POST
CRUD
Soluci贸n del reto de validaci贸n
Solicitudes DELETE
MIddlewares
Middlewares - logger
Middlewares - ErrorHandler
DB
Instalar Postgresql
Instalar Prisma y PostgreSQL Client
Prisma Models
JWT
Autenticaci贸n utilizando JSON Web Tokens (JWT)
Auth - Register
Auth - Login
Expres.js
Arquitectura
Arquitectura parte 2
Creaci贸n y Migraci贸n de Modelos con Prisma para Citas M茅dicas
Admin controllers / services
Admin controllers / services parte 2
Reservations
Reservations parte 2
Appointments
Deploy
PostgreSQL
Deploy
You don't have access to this class
Keep learning! Join and start boosting your career
Creating robust APIs requires not only programming skills, but also the right tools to test and document them. Postman has become an indispensable ally for developers looking to streamline their workflow when building, testing and sharing APIs. In this content, we will explore how to configure Postman to test endpoints in Express.js, a fundamental skill for any backend developer.
Postman is a powerful tool that goes beyond simply testing endpoints. It allows you to document your APIs and create complete resources that you can share with your team. This makes collaboration much easier and ensures that everyone understands how the API you are building works.
There are two main ways to use Postman:
Proper documentation of your APIs is crucial for both your day-to-day professional development and the projects you build. A well-documented API is easier to maintain, scale and share with other developers.
To organize your API tests, it is advisable to create a dedicated workspace:
It is important to mention that Postman offers free functionality for personal use, although it has paid options for collaborative work in teams. For individual projects, the free version is more than enough.
There are several ways to create requests in Postman:
For our case study, we are going to focus on testing two specific endpoints:
(/form
).(/api/data
)// Configuration for the form endpoint// POST /form// Content-Type: application/x-www-form-urlencoded{ " name": "John Tavares", " email": "[email protected]"}
// Configuration for the JSON data endpoint// POST /api/data// Content-Type: application/json{ " key1": "value1", " key2": "value2"}
When testing the endpoint for forms, it is crucial to verify that the field names exactly match what your server expects. In our example:
It is important to note the difference between the field names in the interface and in the programming logic. While in the interface we can use "nombre" (in Spanish), in the backend code we could be using "name" (in English). This distinction is allowed, although the ideal is to maintain consistency using English throughout the code.
When sending the request, we should receive a successful response (code 200 or 201) with the processed data.
For the endpoint that receives JSON data:
{ " key1": "value1", " key2": "value2"}
When sending this request, we should receive a response with code 201 (Created) and an object confirming the data received.
Documentation is an essential part of API development. Not only does it help other developers understand how to use your API, but it also helps yourself when you need to revise it in the future.
It is recommended:
This greatly facilitates collaboration and ensures that anyone working with your API can quickly understand it.
Proper use of tools like Postman not only improves your workflow as a developer, but also raises the quality of your APIs by ensuring they are well tested and documented. Have you used Postman in your projects? Share in the comments how you organize your API testing and what documentation strategies you have found most effective.
Contributions 2
Questions 1
Want to see more contributions, questions and answers from the community?