So today I was trying to verify a CAPTCHA, and somehow is sending me an error (I'm sure I'm doing things okay).
This is the code I wrote to verify it (I'm doing this on the frontend just for education purposes with the CAPTCHA)
try {
const token = document.querySelector('#g-recaptcha-response').value;
let url = 'https://www.google.com/recaptcha/api/siteverify?secret=mysecretkey&response=token'
fetch( url, {
method: 'POST',
mode: 'no-cors',
})
.then(response => response.json())
.then(data => console.log(data));
} catch (err) {
console.log(err);
}
}
I printed in the console the URL so I can access it manually and check if everything is okay (It is okay).
And this is what I have in my contact.vue
<div class="g-recaptcha" data-sitekey="6LfC0kwcAAAAAMZZA0swdErB5_h8y6R_H7hZ85E7" data-size="normal"></div>
The error: Uncaught (in promise) SyntaxError: Unexpected end of input at eval
even inside a trycatch, and when I click on the link where the error is, it points to the line where I do result => result.json()
Any help with this? I'm using Nuxtjs