slightly improved error handling
This commit is contained in:
parent
9f2b80a924
commit
b4e383a09c
@ -73,7 +73,11 @@
|
||||
body: JSON.stringify({ html, image, title, category })
|
||||
});
|
||||
const json = await res.json();
|
||||
if (res.status === 200) {
|
||||
goto(`/a/${json.slug}`);
|
||||
} else {
|
||||
alert(`Error ${res.status}: ${json.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
async function addCategory()
|
||||
|
@ -254,6 +254,7 @@ express()
|
||||
res.end(JSON.stringify({
|
||||
message: `You must supply a category name.`
|
||||
}));
|
||||
return;
|
||||
}
|
||||
const cat = await new Category({ name });
|
||||
await cat.save();
|
||||
|
Loading…
x
Reference in New Issue
Block a user