Tutorial: Create API with loopback IBM

Pedro Antunes
Nerd For Tech
Published in
3 min readApr 13, 2021

--

For this tutorial we will use Node.js and some concepts os JavaScrip an REST

First step is open Node.js command prompt, change the directory and type the following command to install LoopBack 4 CLI:

npm i -g @loopback/cli

Then Run the command to select and clone the todo repository:

lb4 example todo

Switch to the directory.

cd loopback4-example-todo

And finally test the aplication:

npm start

The next Step is to create our app scaffolding begin to write the command:

lb4 app

And Complete the questions with the following answer:

The next step is to add a model,.

To do this just type:

lb4 model

And then answer the following questions an press enter:

The next step is to add Datasource.

Begin to type the following command:

lb4 datasource

And then answer the following questions an press enter:

After that create a .json file with rhe following code:

The next step is to create a repository.

Just type this command:

lb4 repository

And then answer the following questions an press enter:

And the its time to add a controller.

Begin to type:

lb4 controller

And then answer the following questions an press enter:

And finnaly type this code:

npm start

And teste your API on the browser, the output should look like this:

You can test post method like this:

--

--