123456789101112131415161718192021222324252627282930313233343536373839 |
- import { defineMock } from "umi";
- type Product = {
- id: string;
- name: string;
- age: number;
- address: string;
- key: string;
- };
- let products: Product[] = [
- {
- id: "1",
- key: "1",
- name: "胡彦斌",
- age: 32,
- address: "西湖区湖底公园1号",
- },
- {
- id: "2",
- key: "2",
- name: "胡彦祖",
- age: 42,
- address: "西湖区湖底公园1号",
- }
- ];
- export default defineMock({
- "GET /api/products": (_, res) => {
- res.send({
- status: "ok",
- data: products,
- });
- },
- "DELETE /api/products/:id": (req, res) => {
- products = products.filter((item) => item.id !== req.params.id);
- res.send({ status: "ok" });
- },
- });
|