title: Delete an empty folder right after deletion of all the images inside
body: <p>I'm writing a function to delete a user in my application, which is powered by NodeJS Mongoose and Cloudinary, and I want to erase all the pictures the user has uploaded into its personal folder and the folder itself. This is the code I wrote to delete a single user (Please note that the name of the user is the name of its folder):</p>
  
  <pre><code>module.exports = (id, callback) =&gt; {
      User.findByIdAndDelete(id, function (err, user) {
          if (err)
              return callback(err);
  
          if (!user)
              return callback(null, null);
  
  
          cloudinary.api.delete_resources_by_prefix(`${user.username}/`, function (err) {
              if (err &amp;&amp; err.http_code !== 404) {
                  return callback(err);
              }
  
              cloudinary.api.delete_folder(`${user.username}`, function (error, result) {
                  if (error &amp;&amp; error.http_code !== 404) {
                      return callback(error);
                  }
                  return callback(null, `${user.username}`);
              });
          });
      });
  };
  </code></pre>
  
  <p>The issue is when I run it that the second API request replies with this error:</p>
  
  <pre><code>{ message: 'Folder is not empty', http_code: 400 }
  </code></pre>
  
  <p>This is obviously not true because I have deleted the files in the API call above. I checked also the correct behavior of the first call by the UI of cloudinary and everything works right except for the last call. So what I'm asking is:</p>
  
  <ol>
  <li>There's an undocumented method to delete a folder and its content in one single call?</li>
  <li>If not, how can I do that without getting this error?</li>
  <li>There's any workaround that does not involve folders? I have watched tags but I don't know if it could result in a performance degrade.</li>
  </ol>