File tree Expand file tree Collapse file tree 2 files changed +10
-10
lines changed Expand file tree Collapse file tree 2 files changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -21,18 +21,17 @@ class MeiliAxiosWrapper implements Types.MeiliAxiosWrapperInterface {
2121 cancelTokenSource : CancelTokenSource
2222
2323 constructor ( config : Types . Config ) {
24+ const headers : { [ index : string ] : any } = {
25+ ...( config . headers || { } ) ,
26+ 'Content-Type' : 'application/json' ,
27+ }
2428 if ( config . apiKey !== undefined ) {
25- this . instance = instance . create ( {
26- baseURL : config . host ,
27- headers : {
28- 'X-Meili-API-Key' : config . apiKey ,
29- } ,
30- } )
31- } else {
32- this . instance = instance . create ( {
33- baseURL : config . host ,
34- } )
29+ headers [ 'X-Meili-API-Key' ] = config . apiKey
3530 }
31+ this . instance = instance . create ( {
32+ baseURL : config . host ,
33+ headers : headers ,
34+ } )
3635 this . cancelTokenSource = instance . CancelToken . source ( )
3736 this . instance . interceptors . response . use ( ( response ) => response . data )
3837 this . instance . interceptors . request . use ( ( request ) => {
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ export { MeiliSearchTimeOutError }
2626export interface Config {
2727 host : string
2828 apiKey ?: string
29+ headers ?: object
2930}
3031
3132///
You can’t perform that action at this time.
0 commit comments