Comparing version 1.0.2 to 1.0.3
@@ -18,4 +18,4 @@ const Hokage = require('./index') | ||
hokage.listPosts().then(resp => { | ||
console.log(resp) // use resp.body if you need only the body | ||
hokage.listPosts('/id').then(resp => { | ||
// console.log(resp) // use resp.body if you need only the body | ||
}).catch(err => { | ||
@@ -25,3 +25,3 @@ console.log('err', err) | ||
const newPost = await hokage.createPost({ | ||
const newPost = await hokage.createPost('/param', { | ||
title: 'foo', | ||
@@ -28,0 +28,0 @@ body: 'bar', |
@@ -81,4 +81,12 @@ require('isomorphic-fetch'); | ||
this[name] = async (body) => { | ||
let req = this.makeRequest(method, path, body, headers) | ||
this[name] = async (...args) => { | ||
let param = '' | ||
let body = args[0] | ||
if (args.length > 1) { | ||
param = args[0] | ||
body = args[1] | ||
} | ||
let req = this.makeRequest(method, path + param, body, headers) | ||
let resp = this.parseResponse(await fetch(req)) | ||
@@ -85,0 +93,0 @@ return resp |
{ | ||
"name": "hokage", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Javascript library to encapsulate API calls", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
6154
114