aboutsummaryrefslogtreecommitdiffstats
path: root/apps/Notes/helpers/noteActions.js
diff options
context:
space:
mode:
Diffstat (limited to 'apps/Notes/helpers/noteActions.js')
-rw-r--r--apps/Notes/helpers/noteActions.js16
1 files changed, 7 insertions, 9 deletions
diff --git a/apps/Notes/helpers/noteActions.js b/apps/Notes/helpers/noteActions.js
index f67e7a4..f864e58 100644
--- a/apps/Notes/helpers/noteActions.js
+++ b/apps/Notes/helpers/noteActions.js
@@ -4,7 +4,7 @@ import filename from '../helpers/fileName'
export const getNote = async (note, setFetchedNote, t, setPopup, callback) => {
try {
- const {content} = await fetchJson(`/api/note/${note.noteId}`)
+ const {content} = await fetchJson(`/api/notes/${note.noteId}`)
setFetchedNote({ ...note, content})
callback()
} catch (err) {
@@ -50,10 +50,10 @@ export const updateNote = async (e, note, mutateNotes, setAction, t, setPopup) =
try {
mutateNotes(
- await fetchJson('/api/notes', {
+ await fetchJson(`/api/notes/${_id}`, {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({_id, title, noteId, content}),
+ body: JSON.stringify({title, noteId, content}),
})
)
setPopup({
@@ -76,10 +76,8 @@ export const removeNote = (e, _id, mutateNotes, t, setPopup, setAction) => {
const remove = async () => {
try {
await mutateNotes(
- await fetchJson('/api/notes', {
+ await fetchJson(`/api/notes/${_id}`, {
method: 'DELETE',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({_id}),
})
)
setPopup({
@@ -98,8 +96,8 @@ export const removeNote = (e, _id, mutateNotes, t, setPopup, setAction) => {
setPopup({
content: t('notes_remove_confirm'),
- yes: { label: t('remove'), action: remove },
- no: { label: t('cancel'), action: async () => {} },
+ yes: {label: t('remove'), action: remove},
+ no: {label: t('cancel'), action: async () => {}},
error: true,
})
}
@@ -108,7 +106,7 @@ export const exportNote = async note => {
const {title} = note
const {content} = note.content
? note
- : await fetchJson(`/api/note/${note.noteId}`)
+ : await fetchJson(`/api/notes/${note.noteId}`)
saveFile(content, filename(title), 'text/plain')
}