<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Richard</title>
    <description>The latest articles on DEV Community by Richard (@richardbridgeman).</description>
    <link>https://dev.to/richardbridgeman</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F892537%2F55fdf7c0-39d4-495b-86d2-cbd1db95490a.png</url>
      <title>DEV Community: Richard</title>
      <link>https://dev.to/richardbridgeman</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/richardbridgeman"/>
    <language>en</language>
    <item>
      <title>Getting data back from Async function in NextJS</title>
      <dc:creator>Richard</dc:creator>
      <pubDate>Fri, 15 Jul 2022 15:24:55 +0000</pubDate>
      <link>https://dev.to/richardbridgeman/getting-data-back-from-async-function-in-nextjs-59db</link>
      <guid>https://dev.to/richardbridgeman/getting-data-back-from-async-function-in-nextjs-59db</guid>
      <description>&lt;p&gt;I have the following code in &lt;code&gt;/lib/s3libdata.js&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Upload } from "@aws-sdk/lib-storage";
import {S3, S3Client} from "@aws-sdk/client-s3";

export const putObject = async (uploadFilePath, fileStream) =&amp;gt; {
    const upload = new Upload({
        params: {
            Bucket: process.env.AWS_BUCKET,
            Key: uploadFilePath,
            Body: fileStream,
        },
        client: new S3Client({
            region: process.env.AWS_REGION,
            credentials: {
                accessKeyId: process.env.AWS_ACCESS_KEY,
                secretAccessKey: process.env.AWS_SECRET_KEY,
            },
        }),
        queueSize: 3,
    });

    upload.on("httpUploadProgress", (progress) =&amp;gt; {
        console.log(progress);
    });

    await upload.done();
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using the &lt;code&gt;@aws-sdk/lib-storage&lt;/code&gt;.  The upload works, and in my terminal I get the console log output of the progress.  My question now is how do I send that progress information back to the page?&lt;/p&gt;

&lt;p&gt;The way I call this is from &lt;code&gt;/pages/api/upload.js&lt;/code&gt; which is called from &lt;code&gt;/pages/upload.js&lt;/code&gt;.  &lt;/p&gt;

&lt;p&gt;Ideally I want the upload.js page to display the progress data.  How can I achieve this?&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>nextjs</category>
      <category>react</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
