post 写法
let params = {
token: this.token,
username: this.username
}
fetch('http://127.0.0.1:8000/index/', {
method: 'POST',
body: params
}).then(res => res.json())
.then(data => {
console.log('Success:', data);
if (data.msg == '操作成功') {
window.open(process.env.VUE_APP_DZZH_FRONTEND + "?token=" + data.token);
} else {
window.open(process.env.VUE_APP_DZZH_BACKEND);
}
})
get
fetch('http://127.0.0.1:8000/index/?key=value') // 将数据添加到 URL 的查询字符串中
.then(response => response.json())
.then(data => {
console.log('Success:', data);
})
.catch(error => {
console.error('Error:', error);
});