Vue-Mock注册接口实现

// 注册接口
      let users = [
        {username: 'admin',password: '123456'},
        {username: 'leacloud',password: '123456'}
      ]
      app.get('/api/register',(req,res) => {
        const {username,password} = req.query
        const userLen = users.filter(user => user.username == username).length
        if(userLen > 0) {
          res.json({
            code: 1,
            msg: '用户名已存在'
          })
        } else {
          res.json({
            code: 200,
            msg: '注册成功'
          })
        }
      })

 

你可能感兴趣的:(vue)