adding error handling to api.getItem() call