What is the process for transmitting the Firebase token to the Django backend using Vue.js?

Having trouble sending the firebase token to the backend. I initially suspected that the issue was due to the function not being asynchronous, but even after adjusting it, the problem persists. Any assistance or guidance on this matter would be greatly appreciated. Thank you!

user.getIdToken(true)
     .then(function(idToken) {
           const path = 'http://localhost:8000/api/google-login'
           console.log(idToken)
           axios.post(path , idToken)
                  .then((response) => { 
                      console.log('Whether it works or not')                              
                  })
                  .catch((error) => {
                      console.log(error);
                             });
      }).catch(function(error) {
               console.log(error)
      });


The error message in the console shows: "POST http: // localhost: 8000 / api / google-login 500 (Internal Server Error)", however, manually copying and sending the idtoken to the backend seems to work fine.

Answer №1

now is the perfect time, make sure to include your key when sending the token

{{ fetch.post(endpoint , {'token_id':idToken}) }}

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

Setting up nginx for deploying a Vue.js project

I am currently utilizing nginx as my Vue.js dist server. Below is my Nginx configuration: server { listen 80; server_name qy.abc.xyz; charset utf-8; access_log /var/log/nginx/qy.abc.xyz.access.log main; location / { ...

Guide on retrieving the AWS IAM user in string/json format using STS GetCallerIdentity Caller JS/TS

I am attempting to retrieve the AWS IAM Arn user using the STS GetCallerIdentity API provided by Amazon. The following code successfully logs the correct data in the console. Nevertheless, I am encountering difficulty returning the data as a string or JSON ...

Preserve Vue router nested components even after navigating to different pages

Need help with this problem: https://jsfiddle.net/guanzo/myn5o94e/1/ The app defaults to /bar. When you click on "Go to bar child", it goes to /bar/barchild and shows the BarChild component. Clicking on "Go to Foo" navigates to /foo. If you then click on ...

The concept of functions in JavaScript: fact or fiction?

Is there a way to show the message "Yes" or "No" based on the return value of a function without directly using the words true and false, and without utilizing alert? Any suggestions would be greatly appreciated. Thank you. function myFunction { if (Ma ...

Having trouble sending the selected value from a dropdown list to the server using $.ajax

I am embarking on my first project using JQuery (jquery-3.0.0.min.js) and JavaScript. My goal is to build a straightforward web form that connects to a database through a Web API. The form consists of various input text fields and two select dropdowns. ...

Using Angular 2 to implement dynamic variables within HTML

I am struggling with a list that has the following structure: <ul *ngFor="#item of items"> <li><img src="http://something.com/[this needs to be item.id]/picture"></li> </ul> The challenge I am facing is getting the image URL ...

How can I retrieve the record before the current one in a Meteor JS collection?

I need assistance with comparing timestamps and userIds of messages in a collection. Specifically, I want to access the data of the previous message in relation to the current one when rendering each message in the collection. Any tips on how to achieve th ...

Getting a docker-compose application with Django and MongoDB to move past the "Performing system checks..." stage

Setting up a Django application with MongoDB using Djongo. Below is the docker-compose configuration: version: '3.1' volumes: mongo: services: mongodb: image: mongo restart: always volumes: - 'mongo:/data/db' ...

The Vue router fails to navigate to the designated destination

Having an issue with vue-router where routing doesn't work properly when trying to navigate to a child route. { path: '/user', name: 'User', component: User, children: [ { path: 'profile', ...

What is the best way to launch a saved web application with JavaScript?

I'm completely new to the world of PWAs (Progressive Web Apps) and just starting to explore using Angular. Following the instructions in the Angular documentation, I successfully configured a service worker module, and everything seems to be running s ...

Ways to create an AngularJS directive for dynamically allocating scope bindings

Can a directive be used to define the scope bindings of an element? For example: <div g:bind="{width: '=', height: '@'}" width="myWidth" height={{myHeight}}></div> ...

What could be causing the malfunction in this multi-select code developed by loudev?

I tried adding this link: After following the instructions, the code is still not functioning correctly. I made sure to include jQuery scripts as well because I thought they might be necessary. I'm having trouble identifying where the mistake lies. ...

Can you please explain the time and space complexity of this algorithm for obtaining all subarrays of a given array that are divisible by a specified number?

I've been working on a function that takes an array and an integer as parameters, returning an array of subarrays. The number of subarrays exactly matches the integer passed to the function, with each subarray containing continuous elements in the ori ...

What are the steps to automatically populate the location or name in the trip advisor widget?

I have encountered an issue with my website where I have multiple hotel lists but the trip advisor widget only shows one. Is there a solution, such as a script or other method, that can use variables to automatically set the location or name in the widget? ...

The Angular application must remain logged in until it is closed in the browser

Currently, my Angular app includes authentication functionality that is working smoothly. The only issue is that the application/session/token expires when there is no user activity and the app remains open in the browser. I am looking for a solution wher ...

Issue with Dynamic Image Path in Require Function: Unable to locate the relative module

I've been struggling with an error in VueJs require function for the past two days. I'm attempting to pass a prop to the Home component and then display the image. Home.vue <template> <BlogPost :post="welcomeScreen"/> <B ...

Twitter posting unsuccessful: Issue encountered - Your current access is restricted to certain Twitter API v2 endpoints along with limited v1.1 endpoints like media post and oauth

My JavaScript app uses NPM Twit to post on Twitter. Suddenly, my bot stopped working with no explanation. It turns out that Twitter required me to switch to their new free tier and I had to delete all content from my Twitter Dev account and recreate my pro ...

When encountering an error in Laravel Vue related to deleting `␍`, it is possible that using the `--fix` option could provide a potential solution to the issue

When running 'npm run watch', I encountered the following error message: 181 problems (181 errors, 0 warnings) 181 errors and 0 warnings potentially fixable with the --fix option. @ ./resources/js/backend/router/index.js 15:0-41 160:2 ...

Trigger an email notification in Google Sheets whenever a designated cell is populated

I am currently exploring ways to enhance collaboration in project management, especially when dealing with numerous stakeholders (Although there are free tools available, integrating new procedures into a public organization's projects can be quite ch ...

What steps should I take to include a Follow - Unfollow Button on my Website?

I need to add a button on my website that allows users to either follow or unfollow a specific game. Here is the table for the follow buttons: Follow Button Table When a user clicks on the button related to the game ID, it should update the game_follow d ...