【发布时间】:2023-02-15 23:54:00
【问题描述】:
我正在为投资组合目的创建一个类似 netflix 的应用程序,但我遇到了这个错误:未处理的拒绝(TypeError):无法获取。 在我的这部分代码中似乎存在问题:
const [movies, setMovies] = useState([]);
useEffect(() => {
fetch("https://movies-couch-api-herra17.vercel.app/movies")
.then((response) => response.json())
.then((data) => {
console.log(data);
恰好在 .then((响应... 有人可以分享线索,或者可能会知道我还需要审查什么。 我有一个可用的 API。客户端组件是用 React 构建的。 我有以下依赖项:prop-types、react、react-dom、parcel/transformer-sass。
此外,这是我的 index.jsx 的样子:
import { createRoot} from 'react-dom/client';
import { MainView } from './components/main-view/main-view';
// Import statement to indicating bundle is needed import "./index.scss";
// Main component (will eventually use all others)
const MoviescouchApplication = () => { return <MainView />; }; // Find the root of your app const container = document.querySelector("#root"); const root = createRoot(container);
// Tells React to render your app in the root DOM element
root.render(<MoviescouchApplication/>);
【问题讨论】: