Commit 7cd34a85 by Sakilesh J

fix the json-server

parent c5835dbc
NEXT_PUBLIC_API_URL=http://192.168.1.161:4000/
\ No newline at end of file
NEXT_PUBLIC_API_URL=http://localhost:4000/
\ No newline at end of file
{
"tasks": [
{
"id": "1",
"id": 1,
"task": "clg",
"isCompleted": false
},
{
"id": "2",
"id": 2,
"task": "new",
"isCompleted": true
},
{
"id": "3",
"task": "jake",
"isCompleted": false
"isCompleted": true,
"id": 3
},
{
"id": "4",
"task": "new",
"isCompleted": true
"task": "items",
"isCompleted": false,
"id": 5
},
{
"task": "another items",
"isCompleted": false,
"id": 6
}
]
}
\ No newline at end of file
......@@ -3,11 +3,6 @@ import axios from "axios";
export const Axios = axios.create(
{
baseURL: SERVER_URL,
timeout: 3000,
headers: {
"Content-Type": 'application/json',
Accept: 'application/json'
}
baseURL: `${SERVER_URL}tasks/`,
}
)
\ No newline at end of file
......@@ -3,10 +3,9 @@ import { Axios } from "./Instance";
export default async function AddTask(task: string) {
try {
const res = await Axios.post('tasks', {
const res = await Axios.post('', {
task, isCompleted: false
})
alert('Task added successfully')
return res.data
} catch (error) {
alert("something went wrong")
......@@ -19,7 +18,7 @@ export async function DeleteTask(id: number) {
try {
const isDelete = confirm('Are you sure you want to delete');
if (isDelete) {
const res = await Axios.delete(`tasks/${id}`)
const res = await Axios.delete(`${id}`)
return res.data
}
} catch (error) {
......@@ -30,7 +29,7 @@ export async function DeleteTask(id: number) {
}
export async function UpdateTask(id: number, task: string, isCompleted: boolean) {
try {
const res = await Axios.put(`/tasks/${id}`, {
const res = await Axios.put(`${id}`, {
task, isCompleted, id
})
return res.data
......
......@@ -3,7 +3,7 @@ import { Axios } from "./Instance";
export default async function getall() {
try {
const res = await Axios.get('tasks');
const res = await Axios.get('');
return await res.data
} catch (error) {
console.log(error)
......
......@@ -17,7 +17,7 @@
"autoprefixer": "^10.4.17",
"axios": "^1.7.2",
"classnames": "^2.5.1",
"json-server": "^1.0.0-beta.0",
"json-server": "^0.17.2",
"next": "^14.1.0",
"postcss": "^8.4.33",
"react": "^18.2.0",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment