cc-api-next
Advanced tools
Comparing version 1.0.6 to 1.0.7
29
index.js
@@ -8,3 +8,3 @@ const fetch = require('isomorphic-unfetch'); | ||
this.secret = props.secret; | ||
this.tokenKey = props.tokenKey; | ||
this.tokenKey = props.tokenKey || 'token'; | ||
this.headers = { | ||
@@ -48,2 +48,29 @@ "Accept": "application/json", | ||
} | ||
async upload(path, files, data) { | ||
const options = { | ||
method: 'POST', | ||
headers: this.headers | ||
}; | ||
delete options.headers['Accept']; | ||
delete options.headers['Content-Type']; | ||
options.body = new FormData(); | ||
files.map((file, index) => { | ||
options.body.append(`file[${index}]`, file); | ||
}); | ||
for (let key in data) { | ||
options.body.append(key, data[key]); | ||
} | ||
try { | ||
return await fetch(`${this.url}${path}`, options); | ||
} catch (e) { | ||
return e; | ||
} | ||
} | ||
} | ||
@@ -50,0 +77,0 @@ |
{ | ||
"name": "cc-api-next", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "cc api next", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
2294
61
2