Universal npm module to interact with ACM-Planner/main-api.
Install this module with:
npm install --save uc-planner-sdkThis module depends on fetch.
Modern browsers support this feature and fetch is a global function you can use.
You can use whatwg-fetch to support older platforms (not required in React-Native):
npm install --save whatwg-fetchAnd somewhere at the begining of your code:
import 'whatwg-fetch'Then:
import plannerSDK from 'uc-planner-sdk'
const client = plannerSDK({ fetch })
client.courses({ name: 'MAT', year: 2016, period: 2 }).then(result => {
const courses = result.data
const page = result.page
// ...
}).catch(err => {
// ...
})On a Node.js enviorement you can import node-fetch:
npm install --save node-fetchconst fetch = require('node-fetch')
const plannerSDK = require('uc-planner-sdk')
const client = plannerSDK({ fetch })
client.courseSections('MAT1610', { year: 2016, period: 1 }).then(result => {
const sections = result.data
const page = result.page
// ...
})import plannerSDK from 'uc-planner-sdk'
const client = plannerSDK({ fetch })
client.courseSection('MAT1610', 1, { year: 2016, period: 1 }).then(result => {
const section = result.data
})See more examples in test/index.test.js.
Clone this repository:
git clone https://github.com/ACM-Planner/planner-js-sdk.git
cd planner-js-sdkInstall dependencies:
npm installRun test located at test directory with:
npm test