0

I'm creating a small app that gets html from a google form.

The app has only an input and a button.

You should put the link to a google form in the input.

When you push the button the app has to get the HTML from the google form and return it.

I've tried using fetch function to fetch the url od the google form but It shows "Access to fetch at '...' from origin '...' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource."

function App() {

    const getHTML = async () => {
        const resp = await fetch("...")
        const data = await resp.json()
        console.log(resp)
    }

    return (
        <div className="App">
            <button onClick={() => getHTML()}>My Button</button>
        </div>
    );
}

export default App;
Jorge Sánchez
  • 27
  • 1
  • 1
  • 4
  • 1
    You are using `fetch` in the browser, not in Node.js – Quentin Aug 10 '21 at 09:24
  • What's the difference? How can I use it in nodejs? – Jorge Sánchez Aug 10 '21 at 09:26
  • 1
    Browsers enforce the same origin policy as described in the duplicate question. To use it in Node.js you'd have to start by writing a program designed to run in Node.js … which wouldn't be using React which is designed to generate a DOM in a browser. – Quentin Aug 10 '21 at 09:27

0 Answers0