diff --git a/client/components/panels/news-editor.jsx b/client/components/panels/news-editor.jsx
index f091631..e2af6aa 100644
--- a/client/components/panels/news-editor.jsx
+++ b/client/components/panels/news-editor.jsx
@@ -94,6 +94,20 @@ const NewsEditor = props => {
+
);
@@ -125,4 +139,21 @@ const handleSubmit = async (title, author, body, index, tokenFetch) => {
return [null];
};
+const handleDelete = async (index, tokenFetch) => {
+ const conf = confirm('Are you sure you want to delete this article?');
+
+ if (conf) {
+ const result = await tokenFetch(`${process.env.NEWS_URI}/${index}`, {
+ method: 'DELETE'
+ });
+
+ if (!result.ok) {
+ const err = `${result.status}: ${await result.text()}`;
+ return [err, false];
+ }
+ }
+
+ return [null, conf];
+};
+
export default NewsEditor;
\ No newline at end of file
diff --git a/client/components/utilities/token-provider.jsx b/client/components/utilities/token-provider.jsx
index c6c1cef..fdea3df 100644
--- a/client/components/utilities/token-provider.jsx
+++ b/client/components/utilities/token-provider.jsx
@@ -69,9 +69,9 @@ const TokenProvider = props => {
//finally, delegate to fetch
return fetch(url, {
- ...options,
+ ...(options || {}),
headers: {
- ...options.headers,
+ ...(options || { headers: {} }).headers,
'Authorization': `Bearer ${bearer}`
}
});