ошибкаUncaught (in promise) SyntaxError: Unexpected token 'o', "[object Obj"... is not valid JSON
at JSON.parse ()
at run (setTasks.js:6:24)
вид из браузера:
spoiler[{"id":"08dc111b-c255-4311-8464-c5793c2860ca","authorId":"d7ccdf51-374a-47c0-9a04-42ed71e74283","authorName":"savva","createdAt":"2024-01-09T19:03:30.187468","taskText":"Example task","completedAt":null},{"id":"08dc111b-c257-4a26-8e72-6523f99df151","authorId":"d7ccdf51-374a-47c0-9a04-42ed71e74283","authorName":"savva","createdAt":"2024-01-09T19:03:30.207837","taskText":"Example task","completedAt":null},{"id":"08dc111b-c257-4aaa-8fc2-7a849cb2d186","authorId":"d7ccdf51-374a-47c0-9a04-42ed71e74283","authorName":"savva","createdAt":"2024-01-09T19:03:30.208212","taskText":"Example task","completedAt":null},{"id":"08dc111b-c257-4ab8-8070-1ee34fa714dd","authorId":"d7ccdf51-374a-47c0-9a04-42ed71e74283","authorName":"savva","createdAt":"2024-01-09T19:03:30.208239","taskText":"Example task","completedAt":null},{"id":"08dc111b-c257-4ac9-85c3-229f59a60377","authorId":"d7ccdf51-374a-47c0-9a04-42ed71e74283","authorName":"savva","createdAt":"2024-01-09T19:03:30.208267","taskText":"Example task","completedAt":null},{"id":"08dc111c-402b-48bd-8c4a-a3822f0285b1","authorId":"8b0d598e-fca0-438d-9207-871e96488cb2","authorName":"savva","createdAt":"2024-01-09T19:07:01.307331+05:00","taskText":"Example task","completedAt":null},{"id":"08dc111c-402e-42eb-850b-94b5cc06e7ca","authorId":"8b0d598e-fca0-438d-9207-871e96488cb2","authorName":"savva","createdAt":"2024-01-09T19:07:01.3290369+05:00","taskText":"Example task","completedAt":null},{"id":"08dc111c-402e-43a0-8e28-16fe751ca66f","authorId":"8b0d598e-fca0-438d-9207-871e96488cb2","authorName":"savva","createdAt":"2024-01-09T19:07:01.3295525+05:00","taskText":"Example task","completedAt":null},{"id":"08dc111c-402e-43b0-86a2-ed45d8292271","authorId":"8b0d598e-fca0-438d-9207-871e96488cb2","authorName":"savva","createdAt":"2024-01-09T19:07:01.329584+05:00","taskText":"Example task","completedAt":null},{"id":"08dc111c-402e-43c4-81a2-1e657c110e6a","authorId":"8b0d598e-fca0-438d-9207-871e96488cb2","authorName":"savva","createdAt":"2024-01-09T19:07:01.3296159+05:00","taskText":"Example task","completedAt":null}]
ъ
код js setTasks
async function run() {
const response = await fetch("https://localhost:7182/api/Tasking/GetAll/");
const tasks = JSON.parse(await response.json());
return tasks[0].id;
}
run().then(data => console.log(data[0].id));
Как видите в браузере никаких object o нет