未捕获的运行时错误: × 错误 网络错误 AxiosError:网络错误 在 XMLHttpRequest.handleError (http://localhost:3000/static/js/bundle.js:476728:14) 在 Axios.request (http://localhost:3000/static/js/bundle.js:477169:41) 在异步 http://localhost:3000/static/js/bundle.js:2232:11
我正在制作 Study Notion:一个教育技术平台。 当我执行 npm run dev 时,我不会出现此错误,但是当我执行 npm start (即仅启动我的前端)时,就会发生此错误。由于此错误,我无法托管我的网站。
我尝试更新我的 axios 版本,但仍然无法正常工作。请帮忙。
这是我的评论滑块组件
` 从“react”导入 React, { useEffect, useState } 从“react- rating-stars-component”导入ReactStars // 导入 Swiper React 组件 从“swiper/react”导入 { Swiper, SwiperSlide }
// Import Swiper styles
import "swiper/css"
import "swiper/css/free-mode"
import "swiper/css/pagination"
import "../../App.css"
// Icons
import { FaStar } from "react-icons/fa"
// Import required modules
import { Autoplay, FreeMode, Pagination } from "swiper/modules";
// Get apiFunction and the endpoint
import { apiConnector } from "../../services/apiConnector"
import { ratingsEndpoints } from "../../services/apis"
function ReviewSlider() {
const [reviews, setReviews] = useState([])
const truncateWords = 15
useEffect(() => {
;(async () => {
const { data } = await apiConnector(
"GET",
ratingsEndpoints.REVIEWS_DETAILS_API
)
if (data?.success) {
setReviews(data?.data)
}
})()
}, [])
// console.log(reviews)
return (
<div className="text-white">
<div className="my-[50px] h-[184px] max-w-maxContentTab lg:max-w-maxContent">
<Swiper
slidesPerView={4}
spaceBetween={25}
loop={true}
freeMode={true}
autoplay={{
delay: 2500,
disableOnInteraction: false,
}}
modules={[FreeMode, Pagination, Autoplay]}
className="w-full "
>
{reviews.map((review, i) => {
return (
<SwiperSlide key={i}>
<div className="flex flex-col gap-3 bg-richblack-800 p-3 text-[14px] text-richblack-25">
<div className="flex items-center gap-4">
<img
src={
review?.user?.image
? review?.user?.image
: `https://api.dicebear.com/5.x/initials/svg?seed=${review?.user?.firstName} ${review?.user?.lastName}`
}
alt=""
className="h-9 w-9 rounded-full object-cover"
/>
<div className="flex flex-col">
<h1 className="font-semibold text-richblack-5">{`${review?.user?.firstName} ${review?.user?.lastName}`}</h1>
<h2 className="text-[12px] font-medium text-richblack-500">
{review?.course?.courseName}
</h2>
</div>
</div>
<p className="font-medium text-richblack-25">
{review?.review.split(" ").length > truncateWords
? `${review?.review
.split(" ")
.slice(0, truncateWords)
.join(" ")} ...`
: `${review?.review}`}
</p>
<div className="flex items-center gap-2 ">
<h3 className="font-semibold text-yellow-100">
{review.rating.toFixed(1)}
</h3>
<ReactStars
count={5}
value={review.rating}
size={20}
edit={false}
activeColor="#ffd700"
emptyIcon={<FaStar />}
fullIcon={<FaStar />}
/>
</div>
</div>
</SwiperSlide>
)
})}
{/* <SwiperSlide>Slide 1</SwiperSlide> */}
</Swiper>
</div>
</div>
)
}
export default ReviewSlider`
我想你已经添加了
“start”:index.js(导入所有文件的文件)
在 package.json 中的脚本中