@@ -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 }
@@ -214,7 +230,7 @@ export function GlobalField (http, data = {}) {
214230 * client.stack().globalField().create({ global_field })
215231 * .then((globalField) => console.log(globalField))
216232 */
217- this . create = async ( data ) => {
233+ this . create = async ( payload ) => {
218234 try {
219235 if ( this . apiVersion ) {
220236 this . stackHeaders . api_version = this . apiVersion
@@ -224,11 +240,15 @@ export function GlobalField (http, data = {}) {
224240 ...cloneDeep ( this . stackHeaders )
225241 }
226242 }
227- const response = await http . post ( `${ this . urlPath } ` , data , headers )
228- if ( response . data ) {
229- return response . data
243+ const response = await http . post ( `${ this . urlPath } ` , payload , headers )
244+ const data = response . data
245+ if ( data ) {
246+ if ( this . stackHeaders ) {
247+ data . stackHeaders = this . stackHeaders
248+ }
249+ return data
230250 } else {
231- return error ( response )
251+ throw error ( response )
232252 }
233253 } catch ( err ) {
234254 return error ( err )
0 commit comments