localhost_oa_front/mocks/user.ts

25 lines
661 B
TypeScript
Raw Normal View History

2024-02-27 17:22:27 +08:00
import { http, HttpResponse, delay } from 'msw';
import { faker } from '@faker-js/faker/locale/zh_CN';
import { serverApi } from './_util';
export default [
http.get(serverApi('/user/:id'), async () => {
await delay(1000);
return HttpResponse.json(
Array.from({ length: 10 }).map(() => ({
fullname: faker.person.fullName(),
email: faker.internet.email(),
avatar: faker.image.avatar(),
address: faker.location.streetAddress(),
})),
);
}),
http.get(serverApi('/login'), async () => {
await delay(1000);
return HttpResponse.json({
code: 200,
data: '登录成功',
});
}),
];