Search⌘ K
AI Features

Testing the Back-end API

Explore how to test a Node.js back-end API connected to MongoDB by sending GET requests with filters using Insomnia. Understand how to verify data retrieval, apply query filters, and create text indexes in MongoDB Atlas for search functionality.

In this lesson, we’ll test to see if our Node.js back-end server can access the database.

MOVIEREVIEWS_DB_URI=mongodb+srv://admin:hello@cluster0.yjxj4.mongodb.net/sample_mflix?retryWrites=true&w=majority
MOVIEREVIEWS_NS=sample_mflix
PORT=5000
The back-end server we will test

Execute the working example set above and append /api/v1/movies to its URL (see image below). This should return our movie results.

The output should be similar to the image below:

If we see the output above, that means our application has successfully queried the database. We can now test the API in our browser, but it’s better to test our API with a tool called Insomnia.

Setting up

...