52 lines
1021 B
52 lines
1021 B
1 year ago
|
/*
|
||
|
* @Author: October 382756525@qq.com
|
||
|
* @Date: 2022-07-06 11:56:42
|
||
|
* @LastEditors: October 382756525@qq.com
|
||
|
* @LastEditTime: 2022-08-02 15:30:11
|
||
|
* @Description:
|
||
|
*
|
||
|
*/
|
||
|
import { MockMethod } from "vite-plugin-mock";
|
||
|
export default [
|
||
|
{
|
||
|
url: "/api/get",
|
||
|
method: "get",
|
||
|
response: ({ query }) => {
|
||
|
return {
|
||
|
code: 0,
|
||
|
data: {
|
||
|
name: "vben",
|
||
|
sex: "男",
|
||
|
},
|
||
|
};
|
||
|
},
|
||
|
},
|
||
|
{
|
||
|
url: "/api/post",
|
||
|
method: "post",
|
||
|
timeout: 2000,
|
||
|
response: {
|
||
|
code: 0,
|
||
|
data: {
|
||
|
name: "vben",
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
{
|
||
|
url: "/api/text",
|
||
|
method: "post",
|
||
|
rawResponse: async (req, res) => {
|
||
|
let reqbody = "";
|
||
|
await new Promise((resolve) => {
|
||
|
req.on("data", (chunk) => {
|
||
|
reqbody += chunk;
|
||
|
});
|
||
|
req.on("end", () => resolve(undefined));
|
||
|
});
|
||
|
res.setHeader("Content-Type", "text/plain");
|
||
|
res.statusCode = 200;
|
||
|
res.end(`hello, ${reqbody}`);
|
||
|
},
|
||
|
},
|
||
|
] as MockMethod[];
|