Skip to content

Commit

Permalink
feat(core): Add json property to Request
Browse files Browse the repository at this point in the history
Resolves Netflix#7.
  • Loading branch information
offirgolan committed Jun 11, 2018
1 parent 1a86846 commit bb8e1cb
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/@pollyjs/core/src/-private/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import removeHostFromUrl from '../utils/remove-host-from-url';
import serializeRequestBody from '../utils/serialize-request-body';

const { keys, freeze } = Object;
const { parse } = JSON;

const PARSED_URL = Symbol();
const ROUTE = Symbol();
Expand Down Expand Up @@ -106,6 +107,10 @@ export default class PollyRequest {
return typeof this[ROUTE].handler.get('intercept') === 'function';
}

get json() {
return parse(this.body);
}

async setup() {
// Trigger the `beforeRequest` event
await this._trigger('beforeRequest');
Expand Down

0 comments on commit bb8e1cb

Please sign in to comment.