@titanium/please
Advanced tools
Comparing version 0.0.2 to 0.0.3
{ | ||
"name": "@titanium/please", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Titanium native mobile module for politely requesting data", | ||
@@ -44,3 +44,3 @@ "keywords": [ | ||
"@titanium/eslint-config": "0.0.11", | ||
"eslint": "^6.7.2", | ||
"eslint": "^6.8.0", | ||
"lodash": "^4.17.15" | ||
@@ -47,0 +47,0 @@ }, |
@@ -47,3 +47,3 @@ /* eslint-disable promise/avoid-new */ | ||
headers(args = {}) { | ||
console.debug('you are here → please.headers()'); | ||
console.debug('📡 you are here → please.headers()'); | ||
Object.assign(this.config.headers, args); | ||
@@ -64,3 +64,3 @@ return this; | ||
timeout(args) { | ||
console.debug('you are here → please.timeout()'); | ||
console.debug('📡 you are here → please.timeout()'); | ||
this.config.timeout = args; | ||
@@ -71,3 +71,3 @@ return this; | ||
baseUrl(args) { | ||
console.debug('you are here → please.baseUrl()'); | ||
console.debug('📡 you are here → please.baseUrl()'); | ||
this.config.baseUrl = args; | ||
@@ -78,3 +78,3 @@ return this; | ||
url(args) { | ||
console.debug('you are here → please.url()'); | ||
console.debug('📡 you are here → please.url()'); | ||
this.config.url = args; | ||
@@ -84,10 +84,4 @@ return this; | ||
// data(args) { | ||
// console.debug('you are here → please.data()'); | ||
// this.config.data = args; | ||
// return this; | ||
// } | ||
form(args) { | ||
console.debug('you are here → please.form()'); | ||
console.debug('📡 you are here → please.form()'); | ||
this.config.form = args; | ||
@@ -100,3 +94,3 @@ this.config.method = 'POST'; | ||
contentType(value) { | ||
console.debug('you are here → please.contentType()'); | ||
console.debug('📡 you are here → please.contentType()'); | ||
this.header('Content-Type', value); | ||
@@ -107,3 +101,3 @@ return this; | ||
responseType(value = 'json') { | ||
console.debug('you are here → please.responseType()'); | ||
console.debug('📡 you are here → please.responseType()'); | ||
this.responseType = value.toLowerCase(); | ||
@@ -125,3 +119,3 @@ switch (this.responseType) { | ||
header(name, value) { | ||
console.debug('you are here → please.header()'); | ||
console.debug('📡 you are here → please.header()'); | ||
this.config.headers[name] = value; | ||
@@ -132,3 +126,3 @@ return this; | ||
post(args) { | ||
console.debug('you are here → please.post()'); | ||
console.debug('📡 you are here → please.post()'); | ||
if (args) { | ||
@@ -144,3 +138,3 @@ this.config.url = args; | ||
get(args) { | ||
console.debug('you are here → please.get()'); | ||
console.debug('📡 you are here → please.get()'); | ||
this.config.method = 'GET'; | ||
@@ -155,3 +149,3 @@ if (args) { | ||
create() { | ||
console.debug('you are here → please.get()'); | ||
console.debug('📡 you are here → please.get()'); | ||
return new Please(_.cloneDeep(this.config)); | ||
@@ -166,3 +160,2 @@ } | ||
const { config } = this; | ||
// console.debug(`this.config: ${JSON.stringify(this.config, null, 2)}`); | ||
let url; | ||
@@ -197,5 +190,3 @@ _.defaults(this.config, { | ||
// console.debug(`this.config.headers: ${JSON.stringify(this.config.headers, null, 2)}`); | ||
Object.keys(this.config.headers).forEach(header => { | ||
// console.error(`setting header - ${header}:${this.config.headers[header]}`); | ||
xhr.setRequestHeader(header, this.config.headers[header]); | ||
@@ -222,3 +213,3 @@ }); | ||
} catch (err) { | ||
console.error('Please.xhr.onload.parse: Error parsing JSON response.'); | ||
console.error('🛑 Please.xhr.onload.parse: Error parsing JSON response.'); | ||
console.warn(`err: ${JSON.stringify(err, null, 2)}`); | ||
@@ -229,5 +220,2 @@ } | ||
// console.debug(`result.json: ${JSON.stringify(result.json, null, 2)}`); | ||
// console.debug(`result: ${JSON.stringify(result, null, 2)}`); | ||
return resolve(result); | ||
@@ -237,8 +225,8 @@ }; | ||
xhr.onerror = function (response) { | ||
console.debug('you are here → please.xhr.onerror()'); | ||
console.debug('📡 you are here → please.xhr.onerror()'); | ||
try { | ||
response.json = JSON.parse(this.responseText); | ||
} catch (err) { | ||
console.error('Please.xhr.onload.parse: Error parsing JSON response.'); | ||
console.warn(`err: ${JSON.stringify(err, null, 2)}`); | ||
console.error('🛑 Please.xhr.onload.parse: Error parsing JSON response.'); | ||
console.error(`err: ${JSON.stringify(err, null, 2)}`); | ||
} | ||
@@ -248,4 +236,2 @@ | ||
// console.debug(`this.keys: ${JSON.stringify(Object.keys(this), null, 2)}`); | ||
if (response.code === 401) { | ||
@@ -255,3 +241,3 @@ return reject(new UnauthorizedError()); | ||
console.error(`please.xhr.onerror.response: ${JSON.stringify(response, null, 2)}`); | ||
console.error(`🛑 please.xhr.onerror.response: ${JSON.stringify(response, null, 2)}`); | ||
@@ -267,3 +253,3 @@ return reject(new Error({ message: 'Error Occurred', statusCode: response.code, source: response.source })); | ||
} catch (err) { | ||
console.debug('you are here → please.xhr.catch()'); | ||
console.debug('📡 you are here → please.xhr.catch()'); | ||
console.error(`err: ${JSON.stringify(err, null, 2)}`); | ||
@@ -270,0 +256,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12462
203