From 8ba67b92c8956f109daf9af78743f654aec33e67 Mon Sep 17 00:00:00 2001 From: PaulDalek Date: Tue, 6 Aug 2024 15:15:11 +0200 Subject: [PATCH] Updated the Node.js Module example in the README, touch #563. --- README.md | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index effeb48f..bf6045ba 100644 --- a/README.md +++ b/README.md @@ -568,20 +568,24 @@ const options = { } }; -// Initialize export settings with your chart's config -const exportSettings = exporter.setOptions(options); -// Must initialize exporting before being able to export charts -await exporter.initExport(exportSettings); +// Logic must be triggered in an asynchronous function +(async () => { + // Initialize export settings with your chart's config + const exportSettings = exporter.setOptions(options); -// Perform an export -await exporter.startExport(exportSettings, async (error, info) => { - // The export result is now in info - // It will be base64 encoded (info.data) + // Must initialize exporting before being able to export charts + await exporter.initExport(exportSettings); - // Kill the pool when we are done with it - await exporter.killPool(); -}); + // Perform an export + await exporter.startExport(exportSettings, async (error, info) => { + // The export result is now in info + // It will be base64 encoded (info.data) + + // Kill the pool when we are done with it + await exporter.killPool(); + }); +})(); ``` ## CommonJS support