Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

159
Views
La solicitud POST de Vue.JS pasa el token de portador nulo y falló con el código de estado 401

Soy un tipo de back-end que quiere obtener algunas habilidades de Vue.js. En mi aplicación, tengo Ruby on Rails como backend y Vue.js como front-end con un flujo de token JWT estándar. Estoy tratando de enviar una solicitud POST ( fetchAllProductsRequest ) al backend que activará un trabajo en segundo plano usando el siguiente código:

index.js

 const fetchAllProductsRequest = (self) => { const jwtToken = self.$store.state.idToken; return axios .post(`/api/v1/imports/products/fetch_all`,{ headers: { Authorization: `Bearer ${jwtToken}`, 'Content-Type': 'application/json', 'Accept': 'application/json' } }) .then(response => response.data) };

Sorprendentemente, recibo un error: la Request failed with status code 401 . Cuando lo depuro en el lado del backend, veo que envío un token vacío dentro del encabezado:

 [1] pry(#<Api::V1::Imports::ProductsController>)> params[:headers] => #<ActionController::Parameters {"Authorization"=>"Bearer null", "Content-Type"=>"application/json", "Accept"=>"application/json"} permitted: false>

Aquí hay una función que activa fetchAllProductsRequest que es responsable de la solicitud POST:

fetch_all.vue

 <script> import { fetchAllProductsRequest, } from '../../api/imports' import ModalController from '../general/modal_controller' export default { name: 'BackboneFetchAll', data() { return { } }, components: { MoonLoader }, computed: { databaseSyncInProgress() { return this.$store.getters.getDatabaseSyncStatus; }, }, methods: { async syncAll() { let confirmationText = `Do you want to sync all Backbone products?` if (await ModalController.showConfirmation('Confirmation', confirmationText)) { try { ModalController.showLoader() await fetchAllProductsRequest(this) this.$store.commit('setSyncingProductsInProgress', value) const successMessage = `Database synchronization has been queued` await ModalController.showToast('', successMessage) } catch (data) { const errorMessage = `Error occurred during queueing products to sync - ` ModalController.showToast('', errorMessage + data?.message, 'error') } finally { ModalController.hideLoader() } } }, } } </script>

¿Qué me perdí?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!