Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
respond (body, statusCode, headers) {
if (!this.pendingRequestFilterRuleInit)
throw new APIError('respond', RUNTIME_ERRORS.requestHookConfigureAPIError, RequestMock.name, "The 'onRequestTo' method was not called before 'respond'. You must call the 'onRequestTo' method to provide the URL requests to which are mocked.");
const mock = new ResponseMock(body, statusCode, headers);
const rule = new RequestFilterRule(this.pendingRequestFilterRuleInit);
this.requestFilterRules.push(rule);
this.mocks.set(rule, mock);
this.pendingRequestFilterRuleInit = null;
return this;
}
}