我有一个API。我想要的是传递电子邮件的值,看看 API 上是否存在该电子邮件。但每次我运行它并检查控制台日志时,它都会返回未定义?这里的任何人都可以提供更好的代码或方法,我想用 async wait 来完成,而不是 axios 。
const email = this.loginbus.loginemail;
await fetch('http://localhost:8000/api/checklogin', ({'email': email}))
.then((response) => {
console.log(response);
}).then((data) => {
console.log(data);
});
Also tried this. its not working
let result = new Request("http://localhost:8000/api/login", {
method: 'GET',
body:JSON.stringify({ 'email': email}),
})
result = await result.json();
console.log(result);
Laravel 代码控制器:
public function checklogin(Request $request){
//return $request->input('email');
$getVerify = Makatibuspartner::where('email', $request->email)->select('email_verified_at')->first();
if(!$getVerify){
return ["status" => 400, "error" => "Please enter an email/registered email"];
}else if($getVerify && is_null($getVerify->email_verified_at)){
return ["status" => 400, "error" => "Not yet Verified"];
}else{
return ["status" => 200, "message" => "Verified"];
}
}
有人可以给我将变量或电子邮件值传递给 api 的正确方法
GET 没有主体。使用查询参数。
http://localhost:8000/api/checklogin?email=your_email