export default function Feed() {
const [posts, setPosts] = useState([]);
const PF = process.env.REACT_APP_PUBLIC_FOLDER;
useEffect(() => {
const fetchPosts = async () => {
const res = await axios.get("posts/timeline/628f04a81b8f4431e49b6679");
console.log(res);
setPosts(res.data);
};
fetchPosts();
}, []);
在运行这段代码时,我得到以下内容:
GET http://localhost:3000/posts/timeline/628f04a81b8f4431e49b6679 500 (Internal Server Error)
dispatchXhrRequest @ xhr.js:220
xhrAdapter @ xhr.js:16
dispatchRequest @ dispatchRequest.js:58
request @ Axios.js:109
Axios.<computed> @ Axios.js:131
wrap @ bind.js:9
fetchPosts @ Feed.jsx:13
(anonymous) @ Feed.jsx:17
commitHookEffectListMount @ react-dom.development.js:23049
commitPassiveMountOnFiber @ react-dom.development.js:24816
commitPassiveMountEffects_complete @ react-dom.development.js:24781
commitPassiveMountEffects_begin @ react-dom.development.js:24768
commitPassiveMountEffects @ react-dom.development.js:24756
flushPassiveEffectsImpl @ react-dom.development.js:26990
flushPassiveEffects @ react-dom.development.js:26935
(anonymous) @ react-dom.development.js:26725
workLoop @ scheduler.development.js:266
flushWork @ scheduler.development.js:239
performWorkUntilDeadline @ scheduler.development.js:533
这是系统无法获取数据的第一个错误。我被困在这里一段时间了。我是全新的反应,所以如果有人能解决这一问题,并解释,如果你是一个婴儿解释将是伟大的。这样我就能更容易地理解它了。谢谢
Feed.jsx:16 Uncaught (in promise)
AxiosError {message: 'Request failed with status code 500', name: 'AxiosError', code: 'ERR_BAD_RESPONSE', config: {…}, request: XMLHttpRequest, …}
code: "ERR_BAD_RESPONSE"
config: {transitional: {…}, transformRequest: Array(1), transformResponse: Array(1), timeout: 0, adapter: ƒ, …}
message: "Request failed with status code 500"
name: "AxiosError"
request: XMLHttpRequest {onreadystatechange: null, readyState: 4, timeout: 0, withCredentials: false, upload: XMLHttpRequestUpload, …}
response: {data: {…}, status: 500, statusText: 'Internal Server Error', headers: {…}, config: {…}, …}
[[Prototype]]: Error
fetchPosts @ Feed.jsx:16
await in fetchPosts (async)
(anonymous) @ Feed.jsx:17
commitHookEffectListMount @ react-dom.development.js:23049
commitPassiveMountOnFiber @ react-dom.development.js:24816
commitPassiveMountEffects_complete @ react-dom.development.js:24781
commitPassiveMountEffects_begin @ react-dom.development.js:24768
commitPassiveMountEffects @ react-dom.development.js:24756
flushPassiveEffectsImpl @ react-dom.development.js:26990
flushPassiveEffects @ react-dom.development.js:26935
(anonymous) @ react-dom.development.js:26725
workLoop @ scheduler.development.js:266
flushWork @ scheduler.development.js:239
performWorkUntilDeadline @ scheduler.development.js:533
这就是我得到的公理错误
发布于 2022-09-15 05:56:32
打开您的开发工具,然后转到网络并删除用户日志,例如,获取http://localhost:3000/posts/timeline/628f04a81b8f4431e49b6679,删除用户,它就能工作了。
https://stackoverflow.com/questions/72413021
复制相似问题