<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: i want to check is file exists with async/await in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/i-want-to-check-is-file-exists-with-async-await/m-p/680303#M30666</link>
    <description>I just have to look in de root for the file. That’s not the problem. My call comes back undefined and not true or false because the await response does not work.</description>
    <pubDate>Thu, 27 Apr 2023 18:33:30 GMT</pubDate>
    <dc:creator>brtdvrs</dc:creator>
    <dc:date>2023-04-27T18:33:30Z</dc:date>
    <item>
      <title>i want to check is file exists with async/await</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/i-want-to-check-is-file-exists-with-async-await/m-p/680265#M30662</link>
      <description>&lt;P&gt;I tried this but it doesn't work:&lt;/P&gt;&lt;P&gt;async function CheckIfFileExist(dbx, fileName) {&lt;BR /&gt;let fentries = [];&lt;BR /&gt;dbx.filesListFolder({ path: "" })&lt;BR /&gt;.then(async function (response) {&lt;BR /&gt;fentries = await response.result.entries;&lt;BR /&gt;if (fentries &amp;gt; 1) {&lt;BR /&gt;for (let i = 0; i &amp;lt; fentries.length; i++) {&lt;BR /&gt;if (fentries[i].name == fileName) {&lt;BR /&gt;return true&lt;BR /&gt;}&lt;BR /&gt;return false&lt;BR /&gt;}&lt;BR /&gt;} else {&lt;BR /&gt;return false&lt;BR /&gt;}&lt;BR /&gt;})&lt;BR /&gt;.catch(function (error) {&lt;BR /&gt;alert(error);&lt;BR /&gt;});&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Thu, 27 Apr 2023 16:32:30 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/i-want-to-check-is-file-exists-with-async-await/m-p/680265#M30662</guid>
      <dc:creator>brtdvrs</dc:creator>
      <dc:date>2023-04-27T16:32:30Z</dc:date>
    </item>
    <item>
      <title>Re: i want to check is file exists with async/await</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/i-want-to-check-is-file-exists-with-async-await/m-p/680277#M30663</link>
      <description>&lt;P&gt;Please clarify what you mean when you say "it doesn't work". For example, what unexpected error or output do you get from the API?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From what you shared though, note that you need to implement&amp;nbsp;&lt;A href="https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesListFolderContinue__anchor" target="_blank"&gt;filesListFolderContinue&lt;/A&gt; in addition to &lt;A href="https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesListFolder__anchor" target="_blank"&gt;filesListFolder&lt;/A&gt; &lt;A href="https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesListFolder__anchor" target="_blank"&gt;as documented&lt;/A&gt; to make sure you get all entries. You're not guaranteed to get everything back from one call to &lt;A href="https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesListFolder__anchor" target="_blank"&gt;filesListFolder&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, as written, this will only start listing the direct children of the root folder. If you're looking for a file elsewhere, this code won't find it. For example, you would need to set &lt;A href="https://dropbox.github.io/dropbox-sdk-js/global.html#FilesListFolderArg" target="_blank"&gt;FilesListFolderArg&lt;/A&gt;.recursive to true to get nested entries. Also, in case you need to check a team space, check out &lt;A href="https://developers.dropbox.com/dbx-team-files-guide" target="_blank"&gt;the Team Files Guide&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In any case, if you know the actual path to the potential file, you can just call &lt;A href="https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesGetMetadata__anchor" target="_blank"&gt;filesGetMetadata&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Apr 2023 17:10:48 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/i-want-to-check-is-file-exists-with-async-await/m-p/680277#M30663</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2023-04-27T17:10:48Z</dc:date>
    </item>
    <item>
      <title>Re: i want to check is file exists with async/await</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/i-want-to-check-is-file-exists-with-async-await/m-p/680303#M30666</link>
      <description>I just have to look in de root for the file. That’s not the problem. My call comes back undefined and not true or false because the await response does not work.</description>
      <pubDate>Thu, 27 Apr 2023 18:33:30 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/i-want-to-check-is-file-exists-with-async-await/m-p/680303#M30666</guid>
      <dc:creator>brtdvrs</dc:creator>
      <dc:date>2023-04-27T18:33:30Z</dc:date>
    </item>
    <item>
      <title>Re: i want to check is file exists with async/await</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/i-want-to-check-is-file-exists-with-async-await/m-p/680340#M30672</link>
      <description>&lt;P&gt;Thanks for clarifying. It sounds like the issue is more around how async/await itself works in JavaScript. I can only really help with the Dropbox API/SDK in particular, so I recommend referring to a guide/documentation for async/await in JavaScript.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That said, it seems like "await response.result.entries" may not be what you want. Perhaps you mean to await the API call itself?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, "fentries &amp;gt; 1" doesn't seem to make sense. I suspect you meant "fentries.length &amp;gt;= 1" instead.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Apr 2023 19:22:45 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/i-want-to-check-is-file-exists-with-async-await/m-p/680340#M30672</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2023-04-27T19:22:45Z</dc:date>
    </item>
  </channel>
</rss>

