TypeError: json is not iterable MOBX
Получаю json с сервера, но не понимаю как его можно записать в массив объектов? Всегда получаю ошибку, TypeError: json is not iterable
import { makeAutoObservable, makeObservable } from "mobx"
class Todo {
todos = [
{},
]
constructor() {
makeAutoObservable(this);
}
fetchtodo() {
fetch('https://jsonplaceholder.typicode.com/todos/1')
.then(response => response.json())
.then(json => {
console.log(json);
this.todos = [...this.todos, ...json]
})
}
}
export default new Todo