Forum Discussion

severalservals's avatar
severalservals
New Contributor
5 years ago

How to use requestInterceptor in SwaggerUIBundle call

I'm trying to use requestInterceptor in my SwaggerUIBundle call to add a header to the outgoing request. My code is:   window.onload = function() { // Begin Swagger UI call region c...
  • severalservals's avatar
    5 years ago

    I figured it out with the help for a for-in loop to get the properties of the request object. The request object that requestInterceptor gets isn't the one that's described in the Fetch API. It's just got a headers array and you can add directly to it. So:

     

    req.headers['authorization-token'] = 'myheadertokenvalue';

     

    works fine.