Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fetch API issue- code: 'UND_ERR_CONNECT_TIMEOUT' #1042

Open
Rupert91 opened this issue Aug 25, 2024 · 0 comments
Open

fetch API issue- code: 'UND_ERR_CONNECT_TIMEOUT' #1042

Rupert91 opened this issue Aug 25, 2024 · 0 comments

Comments

@Rupert91
Copy link

image 在nextjs 14.2.1里调用radar rules的api,总是显示timeout,不管是用axios方法还是用fetch方法。以下是我的代码:

export default async function Page() {
try {
const response = await fetch('https://rsshub.app/api/radar/rules, {
next: { revalidate: 10 }, // Set revalidation interval if needed
});

if (!response.ok) {
  throw new Error('Failed to fetch data');
}

const data = await response.json();

console.log(data); // You can log the fetched data

return (
  <div>
    <h1>Fetched Data</h1>
    <pre>{JSON.stringify(data, null, 2)}</pre>
  </div>
);

} catch (error) {
console.error('Error fetching data:', error);
return

Failed to fetch data
;
}
}

想知道怎么回事

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant