@@ -102,8 +102,8 @@ const db = factory({
102
102
user: {
103
103
id: primaryKey (String ),
104
104
firstName: String ,
105
- age: Number
106
- }
105
+ age: Number ,
106
+ },
107
107
})
108
108
```
109
109
@@ -1159,7 +1159,7 @@ To gain more control over the mocks and implement more complex mocking scenarios
1159
1159
Take a look at how you can create an entity based on the user's authentication status in a test:
1160
1160
1161
1161
``` js
1162
- import { rest } from ' msw'
1162
+ import { http , HttpResponse } from ' msw'
1163
1163
import { setupServer } from ' msw/node'
1164
1164
import { factory , primaryKey } from ' @mswjs/data'
1165
1165
@@ -1171,17 +1171,17 @@ const db = factory({
1171
1171
})
1172
1172
1173
1173
const handlers = [
1174
- rest .post (' /post' , (req , res , cxt ) => {
1174
+ http .post (' /post' , (req , res , cxt ) => {
1175
1175
// Only authenticated users can create new posts.
1176
1176
if (req .headers .get (' authorization' ) === ' Bearer AUTH_TOKEN' ) {
1177
- return res ( ctx . status ( 403 ) )
1177
+ return new HttpResponse ( null , { status: 403 } )
1178
1178
}
1179
1179
1180
1180
// Create a new entity for the "post" model.
1181
1181
const newPost = db .post .create (req .body )
1182
1182
1183
1183
// Respond with a mocked response.
1184
- return res ( ctx . status ( 201 ), ctx . json ({ post: newPost }) )
1184
+ return HttpResponse . json ({ post: newPost }, { status : 201 } )
1185
1185
}),
1186
1186
]
1187
1187
0 commit comments