@capriza/http-utils
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -19,20 +19,20 @@ var axios = require('axios'); | ||
async get(uri, params, body) { | ||
return this._callRequest("get", uri, params, body); | ||
async get(uri, params, body, priority) { | ||
return this._callRequest("get", uri, params, body, priority); | ||
} | ||
async put(uri, params, body) { | ||
return this._callRequest("put", uri, params, body); | ||
async put(uri, params, body, priority) { | ||
return this._callRequest("put", uri, params, body, priority); | ||
} | ||
async post(uri, params, body) { | ||
return this._callRequest("post", uri, params, body); | ||
async post(uri, params, body, priority) { | ||
return this._callRequest("post", uri, params, body, priority); | ||
} | ||
async downloadUrlAttachment(uri, mediaType) { | ||
var res = await this.get(uri, {responseType : 'arraybuffer'}); | ||
return {data: new Uint8Array(res.data), mediaType: mediaType}; | ||
async downloadUrlAttachment(uri, priority) { | ||
var res = await this.get(uri, {responseType : 'arraybuffer'}, null, priority); | ||
return res && res.data && (new Uint8Array(res.data)); | ||
} | ||
async _callRequest(method, uri, params, body){ | ||
async _callRequest(method, uri, params, body, priority){ | ||
return new Promise((resolve, reject)=>{ | ||
@@ -59,3 +59,3 @@ let func = axios[method]; | ||
this.requestQueue.add(doRequest).then((response)=>resolve(response.data)).catch(onError); | ||
this.requestQueue.add(doRequest, {priority}).then((response)=>resolve(response.data)).catch(onError); | ||
}); | ||
@@ -62,0 +62,0 @@ } |
{ | ||
"name": "@capriza/http-utils", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "HTTP Request utils that handles, request-response, errors, concurrency, priority and authentication", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
19785