@@ -53,7 +53,7 @@ class ReactiveBase extends Component {
5353 ] ,
5454 ( ) => {
5555 this . setStore ( this . props ) ;
56- this . setState ( state => ( {
56+ this . setState ( ( state ) => ( {
5757 key : `${ state . key } -0` ,
5858 } ) ) ;
5959 } ,
@@ -78,28 +78,26 @@ class ReactiveBase extends Component {
7878 }
7979
8080 get headers ( ) {
81- const {
82- headers, reactivesearchAPIConfig, mongodb, endpoint,
83- } = this . props ;
81+ const { headers, reactivesearchAPIConfig, mongodb, endpoint } = this . props ;
8482 const { enableTelemetry } = reactivesearchAPIConfig || { } ;
8583 return {
8684 ...( ! mongodb && {
8785 'X-Search-Client' : X_SEARCH_CLIENT ,
8886 ...( enableTelemetry === false && { 'X-Enable-Telemetry' : false } ) ,
8987 } ) ,
9088 ...headers ,
91- ...( endpoint
92- && endpoint . headers && {
93- ...endpoint . headers ,
94- } ) ,
89+ ...( endpoint &&
90+ endpoint . headers && {
91+ ...endpoint . headers ,
92+ } ) ,
9593 } ;
9694 }
9795
9896 setStore = ( props ) => {
9997 this . type = props . type ? props . type : '*' ;
10098
101- const credentials
102- = props . url && props . url . trim ( ) !== '' && ! props . credentials ? null : props . credentials ;
99+ const credentials =
100+ props . url && props . url . trim ( ) !== '' && ! props . credentials ? null : props . credentials ;
103101
104102 let url = props . url && props . url . trim ( ) !== '' ? props . url : '' ;
105103 if ( props . endpoint instanceof Object ) {
@@ -125,6 +123,7 @@ class ReactiveBase extends Component {
125123 transformResponse : props . transformResponse ,
126124 mongodb : props . mongodb ,
127125 ...( props . endpoint instanceof Object && { endpoint : props . endpoint } ) ,
126+ httpRequestTimeout : props . httpRequestTimeout * 1000 ,
128127 } ;
129128
130129 let queryParams = '' ;
@@ -184,13 +183,13 @@ class ReactiveBase extends Component {
184183 if ( this . props . endpoint && this . props . endpoint . url ) {
185184 // Remove parts between '//' and first '/' in the url
186185 analyticsInitConfig . url = this . props . endpoint . url . replace ( / \/ \/ ( .* ?) \/ .* / , '//$1' ) ;
187- const headerCredentials
188- = this . props . endpoint . headers && this . props . endpoint . headers . Authorization ;
189- analyticsInitConfig . credentials
190- = headerCredentials && headerCredentials . replace ( 'Basic ' , '' ) ;
186+ const headerCredentials =
187+ this . props . endpoint . headers && this . props . endpoint . headers . Authorization ;
188+ analyticsInitConfig . credentials =
189+ headerCredentials && headerCredentials . replace ( 'Basic ' , '' ) ;
191190 // Decode the credentials
192- analyticsInitConfig . credentials
193- = analyticsInitConfig . credentials && atob ( analyticsInitConfig . credentials ) ;
191+ analyticsInitConfig . credentials =
192+ analyticsInitConfig . credentials && atob ( analyticsInitConfig . credentials ) ;
194193 }
195194 } catch ( e ) {
196195 console . error ( 'Endpoint not set correctly for analytics' ) ;
@@ -223,9 +222,9 @@ class ReactiveBase extends Component {
223222
224223 // server side rendered app to collect context
225224 if (
226- typeof window === 'undefined'
227- && props . contextCollector
228- && ! this . calledContextCollector
225+ typeof window === 'undefined' &&
226+ props . contextCollector &&
227+ ! this . calledContextCollector
229228 ) {
230229 this . calledContextCollector = true ;
231230 const res = props . contextCollector ( {
@@ -271,6 +270,7 @@ ReactiveBase.defaultProps = {
271270 graphQLUrl : '' ,
272271 as : 'div' ,
273272 endpoint : null ,
273+ httpRequestTimeout : 30 ,
274274} ;
275275
276276ReactiveBase . propTypes = {
@@ -301,6 +301,7 @@ ReactiveBase.propTypes = {
301301 preferences : types . preferences ,
302302 endpoint : types . endpoint ,
303303 contextCollector : types . func ,
304+ httpRequestTimeout : types . number ,
304305} ;
305306
306307export default ReactiveBase ;
0 commit comments