How can I retrieve the object returned by an external API in VueJS?

I recently integrated the hcaptcha widget into my login component by utilizing the following package: https://github.com/hCaptcha/vue-hcaptcha. The challenge is functioning correctly on the front end.

Upon inspecting the response object in the network tab, I observed that it contains a token and has the following structure:

expiration: 120
generated_pass_UUID: "P0_eyJ0eXAiOiJKV1QiLCJhbG...O9U"
pass: true

My query pertains to how I can pass this token along with my email and password when submitting the login form.

Usually, I use axios for making explicit API calls where I define a variable like:

let response = axios.get('/whatever_api')
and then utilize response.data to access the data received. However, I am unsure of how to proceed with this setup in this case.

Answer №1

Have you experimented with utilizing the @verify="onVerify" event? It appears that the result is triggered by this event. Consider adding a method called onVerify to your vue instance as shown below:

methods: {
  onVerify: function(e) {
    console.log(e);
  } 
}

If the response is successfully returned, you can create an object containing the token, email, and password. From there, proceed with the usual steps.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

V-For with a Twist: Dynamic V-Model

UPDATE Here is a recreation of the issue I am facing I need to dynamically bind with the correct index, how can I achieve this? CLICK THE CODEPEN LINK ABOVE FOR THE OLD CODE CLICK THE CODEPEN LINK ABOVE FOR THE OLD CODE <template> <div> ...

Trouble displaying data table using Vue JS (v-for)

My goal is to display a table of data fetched from Firebase Firestore. I have successfully stored all the data in an array, but when I try to display it, the entire array appears instead of individual items. You can see the issue in the image below: Here& ...

"Utilizing ExpressJS with Mongoose, what is the best method for choosing two column values and converting them

In my current schema setup found in Resource.js file: var mongoose = require("mongoose"), Schema = mongoose.Schema, objectId = mongoose.Schema.ObjectId; var labelShema = new Schema({ labelName: { type: String }, language: { type: String, }, resourceKey: { ...

What is the best way to deploy a React build using Express.js on Elastic Beanstalk?

I'm faced with a challenge in getting elastic beanstalk to properly serve React from Node.js. While everything works fine locally, I'm struggling to configure the path in elastic beanstalk to serve react. In my project, I have an express app.js ...

Accessing store in Vue, the getter function returns a value representing whether the user is currently logged

I have the user state stored in my Vue store, but when I try to access it like this: let isLoggedIn = store.getters.isLoggedIn Instead of getting a simple true or false, I see this in the console: ƒ isLoggedIn (state) { return state.user ? true : false ...

Error: Content Security Policy Blocking Script Loading

I'm fairly new to the world of web development and I'm facing a challenge with a specific script that just won't load. Despite having set my headers to allow certain MIME types and content security policies, I keep encountering errors. The ...

Adding Nuxt.js to an existing Express.js project: A step-by-step guide

Is there a way to export a Nuxt.js project as an Express Middleware? I also need the Nuxt project files to be located outside my Express project. My situation is that I want to integrate an admin dashboard Front-End page into my Back-End project. Nuxt.re ...

Guide to using MongoDB with Express

Why is books.insertOne inserting a null value instead of tmpId, even though console.log(tmpId) displays the correct value? How can this issue be resolved? app.post('/logged/:login/addBook/confirm', urlencodedParser, function(req,res){ var lo ...

I am interested in utilizing node.js to input data into a mongodb Database

Currently, I am working on writing data to a JSON file and retrieving it back to an HTML page for display. Now, I want to achieve the same functionality with a MongoDB database. I have made some attempts, but unfortunately, it is not functioning as expecte ...

.pug form not directing to correct Node.js route handler

On the home page ('/'), I have a basic form that appears. After submitting the form, the browser redirects correctly to the /search route with multiple query parameters: http://localhost:3000/search?allergens=en%3Aegg&preferences=en%3Avegan& ...

Deploying a Nuxt3 application on a static hosting provider may result in an error related to the MIME type of an empty

I recently attempted to deploy my Nuxt3 application on a static file hosting service called "webempresa". After running the npm run generate command for static implementation, I encountered an error when trying to access the site. The console displayed the ...

Using createPersistedState in a vuex and quasar application: A complete guide

Looking for help with using createPersistedState in a vuex and quasar setup. I've been attempting to save some data in the cookie of my application, but it doesn't seem to be working as expected. Any ideas on what could be going wrong? Apprecia ...

Can Angular facilitate the establishment of an Express.js server directly in the browser?

Can an Express.js server be initialized within the browser using Angular? I am interested in executing Node scripts on the Express server via an Angular component. ...

Using Node, Express, and MYSQL to Fetch JSON Data from a MYSQL Database

I have saved JSON data in a database under the accessPoint field, and it appears like this: {"mode": "client", "rate": 0, "ssid": "RMG", "signal": 0, "channel": 0, "password": "", "username": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" ...

Leveraging vuex in conjunction with typescript allows for efficient management of state in namespace modules,

I am currently integrating vuex with typescript and namespaces module in my project. Within this setup, I have two distinct modules: "UserProfile" and "Trips". So far, everything is functioning smoothly within the confines of each module. However, I have ...

Node.js and Express.js are being used in conjunction with Angular to create a server-side controller that fetches all data. However, there seems to be an issue as the

"findByStaff" and "findOne" are working correctly, however, "findAll" is not returning any data. I expected findAll to retrieve all courses from mongodb $scope.findByStaff = function() { $scope.courses = Courses.query(); }; $scope.fin ...

Having issues with utilizing $fetchState in Nuxt 2.12

Recently, I've been exploring the new functionality outlined in the documentation. However, I'm encountering an error that states : Property or method "$fetchState" is not defined on the instance but referenced during render. Despite clearly ...

Having trouble establishing a connection between the client and server while using Node.js with socket.io, Express, and an HTML file

While following a tutorial on YouTube for creating a simple web game with lobbies/rooms, I encountered an issue. When attempting to establish a connection between the client and server, the expected "a user connected" text did not show up in the console as ...

Ensure that every route is prefixed with /api

Is there a way to set all routes accepted by Express to start with /api without explicitly defining it? Current: this.app.get('/api/endpoint-A', (req, res) => { return res.send('A'); }); this.app.get('/api/endpoint-B', ...

The pencil-drawn pixel on the canvas is positioned off-center

Currently, I am using p5.js to draw pixels on canvas with a pencil tool. However, I have encountered an issue where the pixel does not appear centered when the size of the pencil is set to 1 or smaller. It seems to be offset towards the left or right. Upo ...