Monocle API Client for JavaScript
Monocle is a schema-powered API router that focuses on consistency, flexibility and performance.
QuickStart
Getting started with Monocle is simple:
- Add Angular and Monocle scripts to your page
- Add
monocle
as a dependency to your Angular application. - Inject
monocle
and start making API calls!
// Add `monocle` as a dependency:var app = angular; // Inject `monocle` to gain easy access to a Monocle-powered APIapp;
Configuration
The monocle client can be configured in your app's config phase.
// Configure the Monocle client:app;
The monocle node adapter can be configured in your app's config phase.
var monocle = ; // Configure the Monocle Node Adapter:var nodeAdapter = ; // Set a custom timeout to be used by all requests.nodeAdapter; // Set a custom header by value.nodeAdapter; var monocleProvider = nodeAdapter; // Set the host path for API calls.// All API calls will automatically be mounted onto this host path.monocleProvider; // Set the base path for API calls.// All API calls will automatically be mounted onto this base path.monocleProvider;
To make a request with the node adapter or with the monocle client
// FOR GET//The second parameter takes an optional object where props or query can be passed inmonocleProvider