Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add baseUrl for Node.js example #268

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/content/docs/faq.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,19 @@ beforeEach(() => {
})
```

### How to set `baseURL` in Node.js?
Create a custom higher-order function for reusing the same base path with multiple handlers.

``` js
const github = (path) => {
return new URL(path, 'https://github.com').href
}

http.rest.get(github('/repos/:owner/:repo'), resolver)
```

Check out [the rationale](https://github.com/mswjs/msw/pull/406#issuecomment-708519619) for the recommended approach.

## Light theme when?

Whenever you have time to [open a pull request](https://github.com/mswjs/mswjs.io).