From b78ffe029a4857c0ebed4493f2fd1bd83082946d Mon Sep 17 00:00:00 2001 From: Paulo Corcino <7800501+paulocorcino@users.noreply.github.com> Date: Sun, 5 Jun 2022 08:49:45 -0300 Subject: [PATCH] Update README.md (#1698) Fix README.md with reference of constant 'saveCreds' correct on 'creds.update' event. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index aa67e00..20c7477 100644 --- a/README.md +++ b/README.md @@ -145,12 +145,12 @@ import * as fs from 'fs' // utility function to help save the auth state in a single folder // this function serves as a good guide to help write auth & key states for SQL/no-SQL databases, which I would recommend in any production grade system -const { state, saveCreds } = useMultiFileAuthState('auth_info_baileys') +const { state, saveCreds } = await useMultiFileAuthState('auth_info_baileys') // will use the given state to connect // so if valid credentials are available -- it'll connect without QR const conn = makeWASocket({ auth: state }) // this will be called as soon as the credentials are updated -conn.ev.on ('creds.update', saveState) +conn.ev.on ('creds.update', saveCreds) ``` **Note**: When a message is received/sent, due to signal sessions needing updating, the auth keys (`authState.keys`) will update. Whenever that happens, you must save the updated keys (`authState.keys.set()` is called). Not doing so will prevent your messages from reaching the recipient & other unexpected consequences. The `useMultiFileAuthState` function automatically takes care of that, but for any other serious implementation -- you will need to be very careful with the key state management.