@jetthai/cuora 1.0.56 → 1.0.57

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [1.0.57](https://github.com/jetthai/cuora-module/compare/v1.0.56...v1.0.57) (2021-12-16)
6
+
5
7
  ### [1.0.56](https://github.com/jetthai/cuora-module/compare/v1.0.55...v1.0.56) (2021-12-15)
6
8
 
7
9
  ### [1.0.55](https://github.com/jetthai/cuora-module/compare/v1.0.54...v1.0.55) (2021-12-14)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.0.56",
3
+ "version": "1.0.57",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "scripts": {
@@ -0,0 +1,3 @@
1
+ export default {
2
+ upload: (formData) => ({ url: 'upload', method: 'post', params: formData, isFormData: true }),
3
+ }
package/src/api/index.js CHANGED
@@ -5,5 +5,6 @@ import game from './game'
5
5
  import mailbox from './mailbox'
6
6
  import payment from './payment'
7
7
  import user from './user'
8
+ import form from './form'
8
9
 
9
- export default { activity, auth, core, game, mailbox, payment, user }
10
+ export default { activity, auth, core, game, mailbox, payment, user, form }
@@ -70,7 +70,7 @@ export default class Request {
70
70
  }
71
71
 
72
72
  _createConfig(req, cancelToken) {
73
- const { method, url, params, isPublic } = req
73
+ const { method, url, params, isPublic, isFormData } = req
74
74
  // const config = { baseURL: this.config.fullURL, method, url, cancelToken, isPublic: req.isPublic }
75
75
  // if (method.toUpperCase() === 'GET') {
76
76
  // config.params = pickBy(params, isValid)
@@ -79,13 +79,25 @@ export default class Request {
79
79
  // }
80
80
  // return config
81
81
 
82
- return {
83
- baseURL: this.config.fullURL,
84
- method,
85
- url,
86
- cancelToken,
87
- isPublic,
88
- [method.toUpperCase() === 'GET' ? 'params' : 'data']: pickBy(params, isValid),
82
+ if (isFormData) {
83
+ return {
84
+ baseURL: this.config.fullURL,
85
+ method,
86
+ url,
87
+ cancelToken,
88
+ isPublic,
89
+ headers: { 'Content-Type': 'multipart/form-data' },
90
+ data: params,
91
+ }
92
+ } else {
93
+ return {
94
+ baseURL: this.config.fullURL,
95
+ method,
96
+ url,
97
+ cancelToken,
98
+ isPublic,
99
+ [method.toUpperCase() === 'GET' ? 'params' : 'data']: pickBy(params, isValid),
100
+ }
89
101
  }
90
102
  }
91
103