[英]how to send response recaptcha token to backend using axios
我在 vue2 上使用vue-recaptcha v3,当我记录 recaptcha 请求的响应数据时,它是一个带有令牌的完整 promise,当我通过 postman 和谷歌验证 Z8A5DA52ED126447D359E70 时它成功了。 but I don't know how to parse this promise and send the token to the Node backend using axios, my axios section doesn't work and I Get empty object {} at the backend side. 有人可以帮忙吗?
methods: {
loginFunction: function() {
this.$recaptchaLoaded();
const token = this.$recaptcha('login');
console.log(token);
axios.post('http://192.168.27.167:3000/recaptcha',
{
token: token,
})
.then(response => {
}).catch(error => {
console.log(error)
})
它由我的一个朋友解决,如下所示,将 Async Await 添加到代码中,然后在控制台日志中我得到纯令牌以用于验证。
methods: {
loginFunction: async function() {
await this.$recaptchaLoaded();
// Execute reCAPTCHA with action "login".
const gresponse = await this.$recaptcha('login');
console.log(gresponse)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.