How to use the msw.msw.get function in msw

To help you get started, we’ve selected a few msw examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github open-draft / msw / example / src / mocks.js View on Github external
import { msw } from 'msw'

msw.get('https://api.github.com/users/:username', (req, res, { json }) => {
  const { username } = req.params

  return res(
    json({
      avatar_url: 'https://i.imgflip.com/wnv7r.jpg',
      login: username,
      name: 'John Maverick',
      public_repos: Math.ceil(Math.random() * 100),
    }),
  )
})

msw.start()

msw

Seamless REST/GraphQL API mocking library for browser and Node.js.

MIT
Latest version published 7 days ago

Package Health Score

88 / 100
Full package analysis