Commit 3cf242ab by Syed Abdul Rahman

changes in cors handling

parent c96c5244
{
"todos": [
{
"id": "5250",
"title": "qwer",
"id": "a904",
"title": "Buy groceries tomorrow",
"completed": false
},
{
"id": "aeb0",
"title": "qwre",
"id": "a175",
"title": "Travel to head office",
"completed": false
},
{
"id": "7e99",
"title": "qwer",
"completed": false
},
{
"id": "4dca",
"title": "qwer",
"completed": false
},
{
"id": "2c46",
"title": "qwre",
"completed": false
},
{
"id": "224e",
"title": "qwer",
"completed": false
},
{
"id": "023a",
"title": "qre",
"completed": false
},
{
"id": "91d5",
"title": "qwer",
"id": "2753",
"title": "Get phone from head office",
"completed": false
}
]
......
......@@ -17,7 +17,11 @@ function App() {
}, [])
const fetchTodos = async () => {
const response = await fetch('http://localhost:3000/todos');
const response = await fetch('http://localhost:3000/todos', {
headers: {
'Content-Type': 'application/json',
},
});
if (!response.ok) {
console.log("Error fetching data")
}
......@@ -43,7 +47,7 @@ function App() {
}
}
const toggleTodo = async (todoItem: any,e: any) => {
const toggleTodo = async (todoItem: any, e: any) => {
e.stopPropagation()
console.log(todoItem, "todoItem.completed")
await fetch(`http://localhost:3000/todos/${todoItem.id}`, {
......@@ -84,7 +88,7 @@ function App() {
e.stopPropagation()
}
const onSaveEdit = async(e: any, todoId: any) => {
const onSaveEdit = async (e: any, todoId: any) => {
e.stopPropagation();
await fetch(`http://localhost:3000/todos/${todoId}`, {
method: 'PATCH',
......@@ -110,7 +114,7 @@ function App() {
<div className='checklist-item'>
<div className='checklist-item__content' onClick={() => editTodo(ele.id)}>
<input type='checkbox' checked={ele.completed} className='custom-checkbox' onClick={(e) => e.stopPropagation()} onChange={(e) => toggleTodo(ele,e)} />
<input type='checkbox' checked={ele.completed} className='custom-checkbox' onClick={(e) => e.stopPropagation()} onChange={(e) => toggleTodo(ele, e)} />
{editingTodoId === ele.id ? (
<input type='text' value={editableTitle} className='checklist-item__editable-input' onChange={(e) => setEditableTitle(e.target.value)} />
) : (
......
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