@@ -50,7 +50,6 @@ export default class Stack {
50
50
this . config = config ;
51
51
this . cachePolicy = CacheProvider . policies . IGNORE_CACHE ;
52
52
this . provider = CacheProvider . providers ( 'localstorage' ) ;
53
- console . error ( stack_arguments . length ) ;
54
53
55
54
switch ( stack_arguments . length ) {
56
55
case 1 :
@@ -82,39 +81,39 @@ export default class Stack {
82
81
access_token : stack_arguments [ 1 ]
83
82
} ;
84
83
this . environment = stack_arguments [ 2 ] ;
85
- return this ;
86
84
} else {
87
85
console . error ( "Kindly provide valid string parameters." ) ;
88
86
}
89
- if ( stack_arguments [ 3 ] ) {
87
+ if ( stack_arguments [ 3 ] ) {
90
88
if ( typeof stack_arguments [ 3 ] === "string" && stack_arguments [ 3 ] . region !== "us" && stack_arguments [ 3 ] . region === "eu" ) {
91
- config [ 'host' ] = stack_arguments [ 0 ] . region + "-" + "cdn.contentstack.com" ;
89
+ config [ 'host' ] = stack_arguments [ 3 ] + "-" + "cdn.contentstack.com" ;
92
90
} else if ( typeof stack_arguments [ 3 ] === 'object' ) {
93
91
this . fetchOptions = stack_arguments [ 3 ]
94
92
}
95
93
}
94
+ return this ;
96
95
case 5 :
97
96
if ( typeof stack_arguments [ 0 ] === "string" && typeof stack_arguments [ 1 ] === "string" && typeof stack_arguments [ 2 ] === "string" ) {
98
97
this . headers = {
99
98
api_key : stack_arguments [ 0 ] ,
100
99
access_token : stack_arguments [ 1 ]
101
100
} ;
102
101
this . environment = stack_arguments [ 2 ] ;
103
- return this ;
104
102
} else {
105
103
console . error ( "Kindly provide valid string parameters." ) ;
106
104
}
105
+
107
106
if ( stack_arguments [ 3 ] ) {
108
- if ( typeof stack_arguments [ 3 ] === "string" && stack_arguments [ 3 ] . region !== "us" && stack_arguments [ 3 ] . region === "eu" ) {
109
- config [ 'host' ] = stack_arguments [ 0 ] . region + "-" + "cdn.contentstack.com" ;
107
+ if ( typeof stack_arguments [ 3 ] === "string" && stack_arguments [ 3 ] . region !== "us" ) {
108
+ config [ 'host' ] = stack_arguments [ 3 ] + "-" + "cdn.contentstack.com" ;
110
109
} else if ( typeof stack_arguments [ 3 ] === 'object' ) {
111
110
this . fetchOptions = stack_arguments [ 3 ]
112
111
}
113
112
}
114
113
if ( stack_arguments [ 4 ] && typeof stack_arguments [ 4 ] === 'object' ) {
115
- this . fetchOptions = stack_arguments [ 3 ]
114
+ this . fetchOptions = stack_arguments [ 4 ]
116
115
}
117
-
116
+ return this ;
118
117
default :
119
118
console . error ( "Kindly provide valid parameters to initialize the Contentstack javascript-SDK Stack." ) ;
120
119
}
0 commit comments