import qs from 'qs';

export const waitTime = (time = 500) => {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve(true);
    }, time);
  });
};


export const REP_SUCCESS=async (req,res)=>{
    await waitTime();
    return res.json({code:0,data:{}})
}
export const REP_FAIL=async (req,res)=>{
  await waitTime();
  return res.json({code:1,message:'mock失败',data:{}})
}

export const REP_500=async (req,res)=>{
  await waitTime();
  // console.log(res);
  return res.status(500).send({})
}


export const GET_REQUEST=(req)=>{
  if(req.type=='GET'){
    return qs.parse(req.url.split('?')[1]);
  }
  return JSON.parse(req.body);
}
