Skip to content

Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0 #1

@Kathou99

Description

@Kathou99

Hi, When I click submit I got this error,how I can fix it? I have write the same thing has your....

I have added isCaptchaValid(true); for my custom script

And on my side I run on the port 3000 not 4000

const submitData = token => {
      // call a backend API to verify reCAPTCHA response
      fetch('http://localhost:3000/verify', {
        method: 'POST',
        headers: {
          "Content-Type": "application/json"
          
        },
        body: JSON.stringify({
        
          "name": inputName,
          "inputEmail": inputEmail,
          "g-recaptcha-response": token
        })
      }).then(res => res.json()).then(res => {
        isCaptchaValid(true);
        setLoading(false);
        setResponse(res);
      });
    }
This is the error:
<html>
<body>
<!--StartFragment-->

  | Promise.then (async) |   |  
-- | -- | -- | --
  | submitData | @ | form.js:92
  | (anonymous) | @ | form.js:73
  | Promise.then (async) |   |  
  | then | @ | recaptcha__fr.js:172
  | (anonymous) | @ | form.js:72
  | setTimeout (async) |   |  
  | (anonymous) | @ | recaptcha__fr.js:137
  | (anonymous) | @ | recaptcha__fr.js:28
  | handleOnClick | @ | form.js:71
  | callCallback | @ | react-dom.development.js:4111
  | invokeGuardedCallbackDev | @ | react-dom.development.js:4160
  | invokeGuardedCallback | @ | react-dom.development.js:4222
  | invokeGuardedCallbackAndCatchFirstError | @ | react-dom.development.js:4237
  | executeDispatch | @ | react-dom.development.js:9066
  | processDispatchQueueItemsInOrder | @ | react-dom.development.js:9098
  | processDispatchQueue | @ | react-dom.development.js:9111
  | dispatchEventsForPlugins | @ | react-dom.development.js:9122
  | (anonymous) | @ | react-dom.development.js:9314
  | batchedUpdates$1 | @ | react-dom.development.js:25909
  | batchedUpdates | @ | react-dom.development.js:3937
  | dispatchEventForPluginEventSystem | @ | react-dom.development.js:9313
  | dispatchEventWithEnableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay | @ | react-dom.development.js:6489
  | dispatchEvent | @ | react-dom.development.js:6481
  | dispatchDiscreteEvent | @ | react-dom.development.js:6454

<!--EndFragment-->
</body>
</html>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions