Developer Questions

Ask a Question
Back to All

How to close connection or is it how it meant to work

this is my code i'm using to send a signIn payload. everything works fine. only problem i'm wondering is is it normal to keep it logging "New payload event: { expires_in_seconds: xxxxx}" in console every seconds.
i understand the events logs when its in process of signing in but the problem i have is it keep logging even after everything is done. resolved. i think it sorta build up and logs more and more each time. i create a payload eg. a user tried to generate a qrcode.
so my question is how to close connection after its been resolved or reject.

const request= {
TransactionType: "SignIn",
};
const subscription = await Sdk.payload.createAndSubscribe(
request,
(event) => {
console.log("New payload event:", event.data);
if (event.data.signed === true) {
return event.data;
}

  if (event.data.signed === false) {
    return false;
  }
}

);

const resolveData: any = await subscription.resolved;
console.log("resolved")
if (resolveData.signed === false) {
console.log("The sign request was rejected :(");
}
if (resolveData.signed === true) {
console.log("Woohoo! The sign request was signed :)");