1- const API_BASE_URL = process . env . REACT_APP_API_URL || ' http://localhost:8000' ;
1+ const API_BASE_URL = process . env . REACT_APP_API_URL || " http://localhost:8000" ;
22
33class TaskApiService {
44 async request ( endpoint , options = { } ) {
55 const url = `${ API_BASE_URL } ${ endpoint } ` ;
66 const config = {
77 headers : {
8- ' Content-Type' : ' application/json' ,
8+ " Content-Type" : " application/json" ,
99 ...options . headers ,
1010 } ,
1111 ...options ,
1212 } ;
1313
14- if ( config . body && typeof config . body === ' object' ) {
14+ if ( config . body && typeof config . body === " object" ) {
1515 config . body = JSON . stringify ( config . body ) ;
1616 }
1717
1818 try {
1919 const response = await fetch ( url , config ) ;
20-
20+
2121 if ( ! response . ok ) {
2222 throw new Error ( `HTTP error! status: ${ response . status } ` ) ;
2323 }
24-
25- const contentType = response . headers . get ( ' content-type' ) ;
26- if ( contentType && contentType . includes ( ' application/json' ) ) {
24+
25+ const contentType = response . headers . get ( " content-type" ) ;
26+ if ( contentType && contentType . includes ( " application/json" ) ) {
2727 return await response . json ( ) ;
2828 }
29-
29+
3030 return await response . text ( ) ;
3131 } catch ( error ) {
3232 console . error ( `API request failed: ${ endpoint } ` , error ) ;
@@ -36,7 +36,7 @@ class TaskApiService {
3636
3737 // Get all tasks
3838 async getTasks ( ) {
39- return this . request ( ' /v0/task/get_all' ) ;
39+ return this . request ( " /v0/all_tasks" ) ;
4040 }
4141
4242 // Get a specific task by ID
@@ -46,30 +46,30 @@ class TaskApiService {
4646
4747 // Create a new task
4848 async createTask ( taskData ) {
49- return this . request ( ' /v0/task/add/' , {
50- method : ' POST' ,
49+ return this . request ( " /v0/task/add/" , {
50+ method : " POST" ,
5151 body : taskData ,
5252 } ) ;
5353 }
5454
5555 // Update an existing task
5656 async updateTask ( taskId , taskData ) {
5757 return this . request ( `/v0/task/${ taskId } ` , {
58- method : ' PUT' ,
58+ method : " PUT" ,
5959 body : taskData ,
6060 } ) ;
6161 }
6262
6363 // Delete a task
6464 async deleteTask ( taskId ) {
6565 return this . request ( `/v0/task/${ taskId } ` , {
66- method : ' DELETE' ,
66+ method : " DELETE" ,
6767 } ) ;
6868 }
6969
7070 // Health check
7171 async healthCheck ( ) {
72- return this . request ( ' /health' ) ;
72+ return this . request ( " /health" ) ;
7373 }
7474}
7575
@@ -86,4 +86,4 @@ export const {
8686 updateTask,
8787 deleteTask,
8888 healthCheck,
89- } = taskApi ;
89+ } = taskApi ;
0 commit comments