useRouter()
Answered
TK-ed posted this in #help-forum
Answered by Ray
export default function Success({ searchParams }) {
const email = searchParams.email
}the page receive a searchParams object in app router
https://nextjs.org/docs/app/api-reference/file-conventions/page
9 Replies
@TK-ed Im trying to pass a value as query in router but it comes undefined
export default function Success({ searchParams }) {
const email = searchParams.email
}the page receive a searchParams object in app router
https://nextjs.org/docs/app/api-reference/file-conventions/page
Answer
TK-edOP
export default function Success({ searchParams }) {
const email = searchParams
}thanks it worked
TK-edOP
try {
e.preventDefault();
console.log(user);
const response = await axios.post("/api/login", user);
if(response.status==200)
router.push(`/success?email=${user.email}`);
setUser({ email: "", password: "" });
} catch (error) {
console.log("Signup failed", error.message);
}
};so i want to push my page only if the login is successfull but it does tht no matter what, i tried giving status code but it didnt work either
TK-edOP
nope
even if the statuscode isnt 200 it works lol
@TK-ed even if the statuscode isnt 200 it works lol
if(response.data.status==200)this I think?
TK-edOP
lemme try
works thank you pro