Skip to content

Custom HTTP methods #1196

Answered by kettanaito
connorjburton asked this question in Q&A
Discussion options

You must be logged in to vote

Hey, @connorjburton.

You can create your own rest.list() request handler like so:

// my-rest.js
import { rest as defaultRest, RestHandler } from 'msw'

function list(path, resolver) {
  return new RestHandler('list', path, resolver)
}

export const rest = {
  ...defaultRest,
  list,
}

And then use it in your handlers:

import { rest } from './my-rest'

rest.list('/resource', resolver)

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by connorjburton
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
2 participants
Converted from issue

This discussion was converted from issue #1193 on April 06, 2022 10:44.