<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<button class="check">用户验证</button>
<button class="register">用户注册</button>
<!-- 下载 导入 -->
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
<script>
// 测试接口:https://gitee.com/westblueflower/testApi#%E7%94%A8%E6%88%B7
// 用户验证
document.querySelector('.check').onclick = function () {
// 发起请求,校验帐号可用性
axios.post('https://autumnfish.cn/api/user/check', { username: 'thinker' }).then(function (res) {
console.log(res);
})
}
// 用户注册
document.querySelector('.register').onclick = function () {
// 发起请求,进行用户注册
axios.post('https://autumnfish.cn/api/user/register', { username: 'thinker' }).then(function (res) {
console.log(res);
})
}
</script>
</body>
</html>