I am trying to use mock service worker to intercept a response from an endpoint and then modify one field of that json response. If we have an endpoint /user
that returns a json looking like
users: [{
user: {
name: John,
age: 31,
occupation: Engineer
}
}]
I would like to be able to intercept the response from within msw post and change the occupation to be "Student"
So, I believe my handler should return something where it manipulates res
?
rest.post('*/users', (req, res, ctx) => {
return res((res) => {
????
}
}
This general idea wouldn't work because the response mocked response body is Null?