Harmony学习记录
axios
Get
export interface CodeApi{
data: string,
code: number,
message: string
}
.onClick(() =>{
axios<null, AxiosResponse<CodeApi>,null> ({
method: 'get',
baseURL:'http://127.0.0.1:3000',
timeout: 2000,
url: '/word/user/code',
params: {
phone: this.phone
}
}).then((res: AxiosResponse<CodeApi>) => {
this.code = res.data.data
})
}
)
Post
.onClick(() => {
axios.post<null, AxiosResponse<LoginApi>, postUserLogin>("http://127.0.0.1:3000/word/user/login", {
phone: this.phone,
code: this.code
}).then((res: AxiosResponse<LoginApi>) => {
this.token = res.data.data
})
})
export interface LoginApi {
code: number,
message: string,
data: string
}
export interface postUserLogin{
phone: string;
code: string;
}