我试图使用本机脚本在mongodb中存储用户详细信息,但它存储的是空值。电子邮件和密码存储在mongo db中,但它存储的是空值。我不知道问题在哪里。
<template>
<Page>
<ActionBar title="Registerme" />
<ScrollView>
<StackLayout id= "register" class="registered">
<TextField class="email"></TextField>
<TextField class="password"></TextField>
<Button text="Register" @tap="onRegisterTap" />
</StackLayout>
</ScrollView>
</Page>
</template>
<script>
export default {
name: "register",
data() {
return {
email: "",
password: ""
};
},
methods: {
onRegisterTap() {
console.log("submitted..");
const userdetails = {
email: this.email,
password: this.password
};
const options = {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(userdetails)
};
fetch("https://374b5b7a.ngrok.io/register", options)
.then(response => {
console.log("success", response);
})
.catch(error => {
console.error("Error:", error);
});
}
}
}
</script>