export const withDBURL = (uri: string) => `http://localhost:3000${uri}`
export const getUsersFromDB = async () => {
const response = await axios.get(withDBURL('/users'))
return response.data
}
export const addFavouriteMovieToDB = async (user: IUser, movie: IFavouriteMovie) => {
const users: IUser[] = await getUsersFromDB()
const userId: number =
users.findIndex(
// iUser is an iterating user
(iUser: IUser) => iUser.email === user.email && iUser.password === user.password
) + 1
await axios.put(withDBURL(`/users/${userId}`), {
favouriteMovies: [...user.favouriteMovies, movie],
})
}
имеется такой код, почему то в консоль выводится такая ошибка:
index.ts:25 Uncaught (in promise) TypeError: Cannot perform 'get' on a proxy that has been revoked
at index.ts:25:49
at Array.findIndex ()
at addFavouriteMovieToDB (index.ts:23:13)
Что делать??