Giter Site home page Giter Site logo

tksmaru / loopback-example-rest-connector Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hacksparrow/loopback-faq-rest-connector

0.0 2.0 0.0 7.45 MB

http://docs.strongloop.com/display/LB/REST+connector

License: MIT License

JavaScript 100.00%

loopback-example-rest-connector's Introduction

#loopback-example-rest-connector

Overview

This example demonstrates basic usage of loopback-connector-rest.

The project has two servers: local-server and external-server. The "external" server serves a simple REST API, while the local server fetches data using this REST API.

Running the app

$ git clone https://github.com/strongloop/loopback-example-rest-connector.git
$ cd loopback-example-rest-connector/external-server
$ npm install
# node .

In another shell:

$ cd local-server
$ npm install
$ node .

You should see console messages on the local server. Verify the data has been retrieved from the remote server by doing a GET request on Magazines in the explorer or by running curl localhost:3000/api/Magazines.

FAQs

The following are common questions related to using the REST connector.

##How do you perform a GET request to a remote server? In this example, we have a REST API exposed in model-config.json .

To make a request to the remote server, declare new datasource that uses the REST connector in the local datasources.json.

A few things to note in this file is the connector property's value is rest and there is an operations property that takes an array of objects.

This object has two properties: template and function.

The template property contains method which is the HTTP method type to perform the request with and url which is the URL to the remote resource.

The function property is the name of the property you will use to trigger the request. For example, we name our property find because we will trigger the request using Magazine.find()....

The idea is to use find to make a GET request to a url we specify.


Back to top

loopback-example-rest-connector's People

Contributors

deniselee avatar hacksparrow avatar sam-github avatar superkhau avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.