ember-cli-mirage icon indicating copy to clipboard operation
ember-cli-mirage copied to clipboard

# Is it possible to use header keys in mirage ?

Open sarangsbabu367 opened this issue 4 years ago • 3 comments

I am building an ember app and i want to include some additional keys in request header. Is it possible to access these keys from ember-cli-mirage. Since mirage is intercepting and not making any request, i think it wont be possible. Is it ??

sarangsbabu367 avatar Apr 23 '20 17:04 sarangsbabu367

Do you mean you want Mirage to respond to your Ember app with additional headers, in the response? Or you want your Ember app to add additional keys in the headers of the request it makes?

samselikoff avatar Apr 23 '20 18:04 samselikoff

@samselikoff No I am adding headers in my request and i want to get these headers inside mirage.

sarangsbabu367 avatar Apr 26 '20 06:04 sarangsbabu367

this.get('/unitOfMeasures/:name', function (schema, request) {
      let uom = schema.unitOfMeasures.findBy('name', request.params.name);
      return uom;
    });

In the above request.requestHeaders is a hash that has the headers you are looking for. I see the Authorization header when I put a breakpoint in my tests.

cah-brian-gantzler avatar Aug 18 '20 12:08 cah-brian-gantzler