From 92900feda47dee658d90e753c801394e4f074d94 Mon Sep 17 00:00:00 2001 From: Adrien Montfort Date: Thu, 4 Mar 2021 14:27:32 +0100 Subject: [PATCH] Fix documentation around pusher message decompression --- guides/javascript_client/apollo_subscriptions.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/guides/javascript_client/apollo_subscriptions.md b/guides/javascript_client/apollo_subscriptions.md index b312a2987b..fbc268cb8b 100644 --- a/guides/javascript_client/apollo_subscriptions.md +++ b/guides/javascript_client/apollo_subscriptions.md @@ -77,9 +77,11 @@ const pusherLink = new PusherLink({ pusher: pusherClient, decompress: function(compressed) { // Decode base64 - const data = btoa(compressed) + const data = atob(compressed) + .split('') + .map(x => x.charCodeAt(0)); // Decompress - const payloadString = pako.inflate(data, { to: 'string' }) + const payloadString = pako.inflate(new Uint8Array(data), { to: 'string' }); // Parse into an object return JSON.parse(payloadString); }