Skip to content

Commit b89d601

Browse files
committed
s
1 parent 7a541e7 commit b89d601

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/app/lib/data.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ export const deletePost = async (id: string) => {
3232
.eq('id', id); // A condição de deletar pelo id
3333

3434
if (error) throw new Error(error.message);
35-
if (data.length === 0) throw new Error("NO POST FOUND");
35+
if (!data) {
36+
throw new Error("NO POST FOUND");
37+
}
38+
39+
3640
return data;
3741
};
3842

@@ -44,7 +48,7 @@ export const updatePost = async (id: string, title: string, desc: string) => {
4448
.eq('id', id); // A condição de atualizar pelo id
4549

4650
if (error) throw new Error(error.message);
47-
if (data.length === 0) throw new Error("NO POST FOUND");
51+
if (!data) throw new Error("NO POST FOUND");
4852
return data;
4953
};
5054

0 commit comments

Comments
 (0)