0

Am trying to use subscription on my client app to send JWT Token and refreshToken to the server using WebSocketLink connectionParams. But the problem is that my token and refreshToken are saved inside AsynStorage that require me to use async await to get the value out. When i tried to use await, it send undefined to the server.

Here is the code below:

// Create a WebSocket link:
const wsLink = new WebSocketLink({
    uri: wsUri,
    options: {
        reconnect: true,
        connectionParams: async () => {
            return {
                token: await AsyncStorage.getItem('token'),
                refreshToken: await AsyncStorage.getItem('refreshToken')
            }
        }
    }
});

If i set a plan key, it will work. But i need to get the tokens form Async storage using await. How can i go about it?

4

0 回答 0