Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

148
Views
Validate a URL link

I simply want to validate that a link to help text is a valid link when entering the link in a CRUD operation. When I use fetch it fails if the link is to an invalid site, however, not if it is to a bad page on a site (404). The response from the fetch is the same to both a valid page and a non-vaid page, yet google Chrome seems to know.

DevTools image

  const g_log1 = true
  if (g_log1) console.log('URL ', url)
  try {
    const urlOptions = {
      method: 'HEAD',
      mode: 'no-cors',
      headers: { 'Content-Type': 'application/json' }
    }
    fetch(url, urlOptions)
      .then(response => {
        if (g_log1) console.log(url, '--1--', response)
        return true
      })
      .catch(error => {
        if (g_log1) console.log(url, '--2--', error)
        return false
      })
  } catch (error) {
    if (g_log1) console.log(url, '--3--', error)
    return false
  }
}

export default apiCheckURL
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!