From the course: Building APIs with LoopBack
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Understanding remote methods - Node.js Tutorial
From the course: Building APIs with LoopBack
Understanding remote methods
- [Instructor] LoopBack has amazing support for customization across the entire product. Let's begin by talking about one example of that, Remote Methods. Remember that when we defined our model, LoopBack automatically created a set of API's to work with that data. Remote methods simply allow us to define our own API's that extend upon those already made. Remote methods are defined in two ways. First, you will define the path it uses, as well as expected input and output. Then you write the actual logic for whatever it is that particular method does. Basically, one half is metadata, and the other half is the actual implementation. Obviously, what you do here is up to you, and depends on your application. Our LoopBack app has a cat model and one of those properties is breed. We're going to create a new method called adoptable. This method will expect the ID of a cat, and use the following logic to return true or false to determine if a cat can be adopted. If the breed is tiger, then…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.