Update API calls to encode note titles in API URLs
authorAdam Dullage <redacted>
Thu, 4 Jul 2024 17:32:07 +0000 (18:32 +0100)
committerAdam Dullage <redacted>
Thu, 4 Jul 2024 17:32:07 +0000 (18:32 +0100)
client/api.js

index 46e3dcadfb174e5b3827ff800181c008468d05e0..d27d3b5eca0492d6e23600e55379806726a18b6a 100644 (file)
@@ -95,7 +95,7 @@ export async function createNote(title, content) {
 
 export async function getNote(title) {
   try {
-    const response = await api.get(`api/notes/${title}`);
+    const response = await api.get(`api/notes/${encodeURIComponent(title)}`);
     return new Note(response.data);
   } catch (response) {
     return Promise.reject(response);
@@ -104,7 +104,7 @@ export async function getNote(title) {
 
 export async function updateNote(title, newTitle, newContent) {
   try {
-    const response = await api.patch(`api/notes/${title}`, {
+    const response = await api.patch(`api/notes/${encodeURIComponent(title)}`, {
       newTitle: newTitle,
       newContent: newContent,
     });
@@ -116,7 +116,7 @@ export async function updateNote(title, newTitle, newContent) {
 
 export async function deleteNote(title) {
   try {
-    await api.delete(`api/notes/${title}`);
+    await api.delete(`api/notes/${encodeURIComponent(title)}`);
   } catch (response) {
     return Promise.reject(response);
   }
git clone https://git.99rst.org/PROJECT