Define a remote method on a LoopBack model

Bram Borggreve
InstructorBram Borggreve

Share this video with your friends

Send Tweet

In this lesson we look at extending the functionality of LoopBack models by defining a remote method.

A remote method is a method on a model exposed over a custom REST endpoint.

Using the lb remote-method command we will create the remote method meta-data in product.json. We will verify that this got created and that we see the new REST endpoint got added. Then we will create the actual method in product.js and enhance it so that the API will return an error if we want to buy a negative amount of products.

Victor Hazbun
Victor Hazbun
~ 4 years ago

how loopback knows when to return an http 500 error?

Rodolfo
Rodolfo
~ 3 years ago

Hello

When I define a remote method in model.json the id parameters is added, how I can avoid that? when I add the remote method in model.js that does not happen.