Skip to content

Commit e004efb

Browse files
Fixed CLI error issue
1 parent fcbb553 commit e004efb

File tree

3 files changed

+38
-16
lines changed

3 files changed

+38
-16
lines changed

lib/stack/globalField/index.js

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,12 @@ export function GlobalField (http, data = {}) {
5555
if (this.apiVersion) {
5656
delete this.stackHeaders.api_version
5757
}
58-
if (response.data) {
59-
return response.data
58+
const data = response.data
59+
if (data) {
60+
if (this.stackHeaders) {
61+
data.stackHeaders = this.stackHeaders
62+
}
63+
return data
6064
} else {
6165
throw error(response)
6266
}
@@ -105,8 +109,12 @@ export function GlobalField (http, data = {}) {
105109
headers: { ...cloneDeep(this.stackHeaders) }
106110
}
107111
const response = await http.put(`${this.urlPath}`, config, headers)
108-
if (response.data) {
109-
return response.data
112+
const data = response.data
113+
if (data) {
114+
if (this.stackHeaders) {
115+
data.stackHeaders = this.stackHeaders
116+
}
117+
return data
110118
} else {
111119
throw error(response)
112120
}
@@ -146,8 +154,12 @@ export function GlobalField (http, data = {}) {
146154
if (this.apiVersion) {
147155
delete this.stackHeaders.api_version
148156
}
149-
if (response.data) {
150-
return response.data
157+
const data = response.data
158+
if (data) {
159+
if (this.stackHeaders) {
160+
data.stackHeaders = this.stackHeaders
161+
}
162+
return data
151163
} else {
152164
throw error(response)
153165
}
@@ -183,8 +195,12 @@ export function GlobalField (http, data = {}) {
183195
}
184196
}
185197
const response = await http.get(this.urlPath, headers)
186-
if (response.data) {
187-
return response.data
198+
const data = response.data
199+
if (data) {
200+
if (this.stackHeaders) {
201+
data.stackHeaders = this.stackHeaders
202+
}
203+
return data
188204
} else {
189205
throw error(response)
190206
}
@@ -224,11 +240,16 @@ export function GlobalField (http, data = {}) {
224240
...cloneDeep(this.stackHeaders)
225241
}
226242
}
243+
227244
const response = await http.post(`${this.urlPath}`, data, headers)
228-
if (response.data) {
229-
return response.data
245+
let data = response.data
246+
if (data) {
247+
if (this.stackHeaders) {
248+
data.stackHeaders = this.stackHeaders
249+
}
250+
return data
230251
} else {
231-
return error(response)
252+
throw error(response)
232253
}
233254
} catch (err) {
234255
return error(err)

types/stack/globalField/index.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ export interface GlobalField extends SystemFields, SystemFunction<GlobalField> {
88

99
export interface GlobalFields extends Queryable<GlobalField, {global_field: GlobalFieldData}> {
1010
import(data: {global_field: string}, params?: any): Promise<GlobalField>
11-
(globalFieldUidOrOptions: string | { api_version?: string }, options?: { api_version?: string }): GlobalField;
1211
}
1312

1413
export interface GlobalFieldData extends AnyProperty {

types/stack/index.d.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,12 @@ export interface Stack extends SystemFields {
6161
contentType(): ContentTypes
6262
contentType(uid: string): ContentType
6363

64-
globalField(): GlobalFields
65-
globalField({}): GlobalFields
66-
globalField(uid: string): GlobalField
67-
globalField(uid: string, option: object): GlobalField
64+
globalField(): GlobalFields;
65+
globalField(uid: string, option?: object): GlobalField;
66+
globalField(options: { api_version: string }): GlobalFields;
67+
globalField(uidOrOptions?: string | { api_version: string }, option?: object): GlobalFields | GlobalField;
68+
69+
6870

6971
asset(): Assets
7072
asset(uid: string): Asset

0 commit comments

Comments
 (0)