0.3.0 • Published 10 years ago

luu v0.3.0

Weekly downloads
4
License
MIT
Repository
github
Last release
10 years ago

luu

Latest Stable Version License

A Node.js client library for the University of Waterloo's Open Data API.

Installation

npm install --save luu

Usage

Import the Client from luu.

import { Client } from 'luu';

const client = new Client('YOUR_API_KEY');

Make a request.

// request() returns a promise which resolves to a Fetch Response object
// the client will reject the promise automatically for non 200-level HTTP responses
client.request('foodservices/menu')
  .then(response => response.json())
  .then(console.log)
  .catch(console.error);

You can specify parameters for the endpoint string as well. This library uses sprintf-js to parse the endpoint string. Pre-defined parameterized endpoint strings are exported through Constants.

import { Constants } from 'luu';

client.request(Constants.FS_YEAR_WEEK_MENU, {
  year: 2015,
  week: 2,
}).then(console.log);

// equivalent to
client.request('foodservices/%(year)s/%(week)s/menu', {
  year: 2015,
  week: 2,
}).then(console.log);

// specify an array of parameters
client.request(Constants.FS_YEAR_WEEK_MENU, [2015, 2]).then(console.log);
0.3.0

10 years ago

0.2.2

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.1.5

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago