0

Hello I'm learning how to web scrape in react.js, I tried to get data from the imdb website but the website blocks me. I looked for solutions online for react but none of them were clear to me.

this is the full error:

Access to fetch at 'https://www.imdb.com/' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

and this is the code

import React from 'react'
import "./pagesCss/FindMovie.css"


function FindMovie() {

  fetch("https://www.imdb.com/")
    .then(response => response.text())
    .then(data => {
      console.log(data)
    })



  return (
    <div className="pageHead page1">
        <input className='movieNameSearch'  placeholder='Search Movie/Show' />
    </div>
  )
}

export default FindMovie

thanks for helping!

THW 10
  • 51
  • 4
  • 1
    `https://www.imdb.com/` simply isn't configured for CORS. Read https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS – jub0bs Apr 18 '22 at 12:04

0 Answers0