Ember.js: use body-parser library in mocking backend with mirage -
i'm developing ember.js application authenticates against oauth2 endpoint.
in order mock endpoint, use ember-cli-mirage
needs parse http post having content-type
of x-www-form-urlencoded
.
i decided use body-parser
npm package in order parse body of request.
currently have code in config.js
:
var urlencodedparser = bodyparser.urlencoded({ extended: false }); this.post('/login', (schema, request) => { });
i know request.requestbody
contains data i'd parse, can't find correct way make use of 'urlencodedparser` in order parse data.
help appreciated.
const requestpayload = json.parse(request.requestbody);
headers can found in request.requestheaders
. don't need 3rd-party library this.
Comments
Post a Comment