@@ -54,6 +54,7 @@ const ReactiveBase = {
5454 mongodb : types . mongodb ,
5555 endpoint : types . endpointConfig ,
5656 preferences : VueTypes . object ,
57+ httpRequestTimeout : VueTypes . number . def ( 30 ) ,
5758 } ,
5859 provide ( ) {
5960 return {
@@ -94,23 +95,26 @@ const ReactiveBase = {
9495 mongodb ( ) {
9596 this . updateState ( this . $props ) ;
9697 } ,
98+ httpRequestTimeout ( ) {
99+ this . updateState ( this . $props ) ;
100+ } ,
97101 } ,
98102 computed : {
99103 getHeaders ( ) {
100104 const { enableAppbase, headers, appbaseConfig, mongodb, endpoint } = this . $props ;
101105 const { enableTelemetry } = appbaseConfig || { } ;
102106 return {
103- ...( enableAppbase
104- && ! mongodb && {
105- 'X-Search-Client' : X_SEARCH_CLIENT ,
106- ...( enableTelemetry === false && { 'X-Enable-Telemetry' : false } ) ,
107- } ) ,
107+ ...( enableAppbase &&
108+ ! mongodb && {
109+ 'X-Search-Client' : X_SEARCH_CLIENT ,
110+ ...( enableTelemetry === false && { 'X-Enable-Telemetry' : false } ) ,
111+ } ) ,
108112 ...headers ,
109- ...( enableAppbase
110- && endpoint
111- && endpoint . headers && {
112- ...endpoint . headers ,
113- } ) ,
113+ ...( enableAppbase &&
114+ endpoint &&
115+ endpoint . headers && {
116+ ...endpoint . headers ,
117+ } ) ,
114118 } ;
115119 } ,
116120 } ,
@@ -120,8 +124,8 @@ const ReactiveBase = {
120124 this . key = `${ this . state . key } -0` ;
121125 } ,
122126 setStore ( props ) {
123- const credentials
124- = props . url && props . url . trim ( ) !== '' && ! props . credentials
127+ const credentials =
128+ props . url && props . url . trim ( ) !== '' && ! props . credentials
125129 ? null
126130 : props . credentials ;
127131 let url = props . url && props . url . trim ( ) !== '' ? props . url : '' ;
@@ -149,6 +153,7 @@ const ReactiveBase = {
149153 analyticsConfig : props . appbaseConfig ,
150154 mongodb : props . mongodb ,
151155 endpoint : props . endpoint ,
156+ httpRequestTimeout : ( props . httpRequestTimeout || 0 ) * 1000 || 30000 ,
152157 } ;
153158 let queryParams = '' ;
154159
@@ -217,13 +222,13 @@ const ReactiveBase = {
217222 / \/ \/ ( .* ?) \/ .* / ,
218223 '//$1' ,
219224 ) ;
220- const headerCredentials
221- = this . $props . endpoint . headers && this . $props . endpoint . headers . Authorization ;
222- analyticsInitConfig . credentials
223- = headerCredentials && headerCredentials . replace ( 'Basic ' , '' ) ;
225+ const headerCredentials =
226+ this . $props . endpoint . headers && this . $props . endpoint . headers . Authorization ;
227+ analyticsInitConfig . credentials =
228+ headerCredentials && headerCredentials . replace ( 'Basic ' , '' ) ;
224229 // Decode the credentials
225- analyticsInitConfig . credentials
226- = analyticsInitConfig . credentials && atob ( analyticsInitConfig . credentials ) ;
230+ analyticsInitConfig . credentials =
231+ analyticsInitConfig . credentials && atob ( analyticsInitConfig . credentials ) ;
227232 }
228233 } catch ( e ) {
229234 console . error ( 'Endpoint not set correctly for analytics' ) ;
0 commit comments