refactor(auth-dapp): narrow type on auth_response handler

This commit is contained in:
Ben Kremer
2022-09-17 13:08:11 +02:00
parent 44d11ddfbd
commit e8c7bf9c0c
+9 -3
View File
@@ -48,10 +48,16 @@ const Home: NextPage = () => {
useEffect(() => {
if (!client) return;
client.on("auth_response", (res) => {
if (res.params.result.s) {
setAddress(res.params.result.p.iss.split(":")[4]);
client.on("auth_response", ({ params }) => {
if ("code" in params) {
console.error(params);
return;
}
if ("error" in params) {
console.error(params.error);
return;
}
setAddress(params.result.p.iss.split(":")[4]);
});
}, [client]);