Skip to content

Commit 61dc4fe

Browse files
Add async to mockIf callback in README
The callback function passed into mockIf() should be an async function. I followed this example down to the letter but it wouldn't work until I put an async in front of the callback - evidently there is a function somewhere in the stack that requires it.
1 parent 46e09b9 commit 61dc4fe

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ To enable mocking for a specific URL only:
8484
```js
8585
beforeEach(() => {
8686
// if you have an existing `beforeEach` just add the following lines to it
87-
fetchMock.mockIf(/^https?:\/\/example.com.*$/, req => {
87+
fetchMock.mockIf(/^https?:\/\/example.com.*$/, async (req) => {
8888
if (req.url.endsWith('/path1')) {
8989
return 'some response body'
9090
} else if (req.url.endsWith('/path2')) {

0 commit comments

Comments
 (0)