hapi-swaggered icon indicating copy to clipboard operation
hapi-swaggered copied to clipboard

How to add header to request?

Open vforv opened this issue 8 years ago • 1 comments

Is there any way to send also header with requests?

vforv avatar Oct 19 '17 19:10 vforv

The only way i found to achieve this is to set a requestInterceptor in the swagger-ui init (in index.hbs of hapi-swaggered-ui) : Something like this in the SwaggerUIBundle(Object.assign({....

requestInterceptor: (req) => {
      req.headers.Authorization = 'Bearer ' + localStorage.getItem('token');
      return req;
},

m1m1s1ku avatar Apr 12 '18 20:04 m1m1s1ku