Rewrite the "delete" function and use the Promise returned by "$ressource.query()" before fetching an array element.