Cloudflare DevelopersCD
Cloudflare Developers16mo ago
2 replies
Lind

I have question regarding Cloudflare

I have question regarding Cloudflare Snippets.
Docs says that 2 subrequest are allowed but:
async function getNTPTime() {
  const ntpApiUrl = 'http://worldtimeapi.org/api/timezone/Etc/UTC';
  
  try {
    const ntpResponse = await fetch(ntpApiUrl);
    
    if (!ntpResponse.ok) {
      throw new Error(`NTP server responded with status ${ntpResponse.status}`);
    }

    const ntpData = await ntpResponse.json();
    const epochTimeInMs = ntpData.unixtime * 1000;

    return epochTimeInMs;
  } catch (error) {
    throw new Error("Failed to fetch NTP time: " + error.message);
  }
}

This REST request return Error: Failed to fetch NTP time: NTP server responded with status 520
What could be the cause?
Was this page helpful?