Comments for Delete a Note


#21

From @jayair on Fri Apr 20 2018 17:30:31 GMT+0000 (UTC)

@alex-romanov A couple of things to check. Check the CORS config we set in this chapter - https://serverless-stack.com/chapters/create-an-s3-bucket-for-file-uploads.html. And make sure the IAM policy in the chapter is set properly - https://serverless-stack.com/chapters/create-a-cognito-identity-pool.html. There are also some tips on debugging the IAM policy here - https://serverless-stack.com/chapters/debugging-serverless-api-issues.html#missing-iam-policy.


#22

Added a delete function to aws-libs. It works but how can I get information out of the promise I get from delete a file? I want to know if the delete was succesfull e.g. if the file existed. The docs says: * Promise resolves upon successful removal of the object but I don’t know what that means.

 export async function s3Delete(filename) {
     const promise = await Storage.vault.remove(filename);
 
     //how do I check if object was successfully removed?
 
     return true;
 }

#23

I’m not entirely sure for this case but for promises with async/await you want to use the try/catch pattern. So wrap it in a try/catch and it should throw an error if it failed to remove it.