Activities

ricardogobbosouza

ricardogobbosouza posted a new feature request

axios-module •

idea Run Codecov hook

What problem does this feature solve?

Run Codecov hook

ricardogobbosouza

ricardogobbosouza posted a new question

axios-module •

Run Codecov hook

Run Codecov hook

silverbackdan

silverbackdan posted a new bug report

axios-module •

bug Canceling a request doesn't respect 'progress' option

Version

5.3.1

Reproduction link

https://codesandbox.io/s/kmojxplqz5

Steps to reproduce

See https://codesandbox.io/s/kmojxplqz5 - cancel a request using a cancel token once the request has started with the progress option as false.

What is expected ?

No progress bar to show

What is actually happening?

The 'failed' progress bar shows

silverbackdan

silverbackdan posted a new question

axios-module •

Canceling a request doesn't respect 'progress' option

It appears when cancelling a request which has been made with the option progress as false, the progress bar appears on the page in the failed colour (red by default).

Is there another option to insert when cancelling using the cancel token method as described in the axios docs?

Thanks in advance.

ricardogobbosouza

ricardogobbosouza posted a new feature request

axios-module •

idea Run CircleCI on PRs

What problem does this feature solve?

Run CircleCI on PRs

hardikshah91

hardikshah91 posted a new question

axios-module •

In Safari originalRequest headers is not getting updated with new token

@pi0 @manniL
In Safari,

originalRequest.headers['Authorization'] = Bearer ${newToken} is not getting updated with new token
also tried with custom header
originalRequest.headers['Authorization-Bearer'] = Bearer ${newToken}

But still not working. Any solution for it ??

_Originally posted by @Mothirajha in https://github.com/nuxt-community/axios-module/issues/84#issuecomment-460254555_

cloudbluedigital

cloudbluedigital posted a new question

axios-module •

setting token on SSR but it's then not available on client side

Hi

So I am doing something like this:

  actions: {
    async nuxtServerInit({ commit }, { app, $axios }) {
      let auth = null
      const cookie = app.$cookies.get('token'),
        user = app.$cookies.get('user'),
        organisation = app.$cookies.get('organisation')
      $axios.setToken(cookie, 'Bearer')

and then within the code I do

    methods: {
      async fetchQuestionnaire() {
        // If I do the setToken method below it does work normally
        // this.$axios.setToken(this.$cookies.get('token'), "Bearer") 
        let questionnaire_id = this.$route.params.questionnaire_id
        await this.$axios.$get('questionnaires/template/' + questionnaire_id)
          .then(response => {
            this.questionnaires = response
          })
      }

but I am getting 401 as token is not actually being passed. Is there a way to share set token between SSR and client side?

manniL

manniL posted a new bug report

axios-module •

bug Bearer token on SSR

Version

v5.1.0

Reproduction link

https://github.com/nuxt-community/modules/issues/89

Steps to reproduce

See https://github.com/nuxt-community/modules/issues/89

What is expected ?

-

What is actually happening?

-

DreamCatcherJ

DreamCatcherJ posted a new question

axios-module •

How to use axios to upload file in formdata?

How to use axios to upload file in formdata?

LTroya

LTroya posted a new question

axios-module •

How to create multiples $axios instances

Is there a way to create multiple $axios instances?

This is what I do with axios:

const apiInstance = axios.create({
    baseURL: process.env.baseUrl
});

const bcmAxiosInstance = axios.create({ 
    baseURL: 'URL_1',
    headers: {
        common: {
            'api-key': 'SOME_API_KEY,
            'bcm-project-id': 'SOME_PROJECT_ID'
        }
    }
});

I could create one client, but the first one doesn't accept api-key as a header, it gives me a CORS error.

aureliendebord

aureliendebord posted a new question

axios-module •

ERROR Request failed with status code 403

Hello,

My nuxt app is fetching a WordPress API to display posts. No authorization is required.
When I deploy the app on heroku, its works… But after a few hours, the app crashes with this log.
Has anyone already encountered this problem? I'm pretty confused on this…

ERROR  Request failed with status code 403

at createError (node_modules/axios/lib/core/createError.js:16:15)at settle (node_modules/axios/lib/core/settle.js:18:12)
at IncomingMessage.handleStreamEnd (node_modules/axios/lib/adapters/http.js:201:11)
at IncomingMessage.emit (events.js:193:15)
at IncomingMessage.EventEmitter.emit (domain.js:441:20)
at endReadableNT (_stream_readable.js:1129:12)
at process.internalTickCallback (internal/process/next_tick.js:72:19)

My code:
index.vue

async asyncData({ params }) {
  try {
    let { data } = await api.getReferences();
    let { data: data2 } = await api.getBlogHome();

    return {
      references: data,
      bloghome: data2
    };
  } catch (error) {
    console.error(error);
  }
}

api.js

getReferences() {
    return new Promise((resolve, reject) => {
      request.defaults.baseURL = this.baseUrl;
      request.get(`posts?categories=46&per_page=6`).then(response => {
        const data = [...response.data];
        if (response.status === 200 && response.data.length > 0) {
          const filtered = {
            data: data.map(item => ({
              id: item.id,
              title: item.title.rendered,
              excerpt: item.excerpt.rendered,
              slug: item.slug,
              image: item.images.large
            }))
          };
          resolve(filtered);
        } else {
          reject(response);
        }
      });
    });
},


getBlogHome() {
    return new Promise((resolve, reject) => {
      request.defaults.baseURL = this.baseUrl;
      request
        .get(`posts?categories=14,15,16,17,2&per_page=3`)
        .then(response => {
          const data = [...response.data];
          if (response.status === 200 && response.data.length > 0) {
            const filtered = {
              data: data.map(item => ({
                id: item.id,
                title: item.title.rendered,
                excerpt: item.excerpt.rendered,
                slug: item.slug,
                image: item.images.large
              }))
            };
            resolve(filtered);
          } else {
            reject(response);
          }
        });
    });
},
fitsumbelay

fitsumbelay posted a new question

axios-module •

axios module Interceptors not working with vuex

am new to nuxtjs vuex and axios as my project getting bigger i choose to build with nuxt/axios and nuxt/auth but after loginedin when i go to jwt protected route from my api its showing me error 401. then i try to use axios module Interceptors to send auth user token in the header using bearer token.
inside '~/plugins/axios'

export default function ({ $axios, redirect }) {
$axios.onRequest(config => {
  this.$axios.setToken('123', 'Bearer')
})
}

inside 'store.js'

export const actions = {
  async load_cdata ({commit}, url){
      const {data} = await axios.get(url)

      commit('setData', data)

  },

then i get error
pluginsaxiosWEBPACKIMPORTEDMODULE_3.default.get is not a function
PLEASE ANY ONEWHO KNOW HOW TO USE NUXT/AXIOS MODULE INTERCEPTORS WITH NUXTJS

fitsumbelay

fitsumbelay posted a new question

axios-module •

axios module Interceptors not working with vuex

am new to nuxtjs vuex and axios as my project getting bigger i choose to build with nuxt/axios and nuxt/auth but after loginedin when i go to jwt protected route from my api its showing me error 401. then i try to use axios module Interceptors to send auth user token in the header using bearer token.
inside '~/plugins/axios'
export default function ({ $axios, redirect }) {
$axios.onRequest(config => {
this.$axios.setToken('123', 'Bearer')
})
}

inside 'store.js'
export const actions = {
async load_cdata ({commit}, url){
const {data} = await axios.get(url)

  commit('setData', data)

},
..
then i get error
pluginsaxiosWEBPACKIMPORTEDMODULE_3.default.get is not a function
PLEASE ANY ONEWHO KNOW HOW TO USE NUXT/AXIOS MODULE INTERCEPTORS WITH NUXTJS

GMounir

GMounir posted a new question

axios-module •

Login Without password only with token

Hello,
I have a question.. i want to login the user when is activated his account from email
without login using auth.login() function
i'm using JWT for the backend

ruudboon

ruudboon posted a new question

axios-module •

NFR Set timeout from config

Could you please add an option to set the timeout in the config?
The default timeout of axios is 0 (infinite) and I would like it to throw an error after x seconds.

geoffreylzf

geoffreylzf posted a new question

axios-module •

Axios Dynamic BaseUrl

Hi All,

I manage to learn nuxt by using following tutorial

https://scotch.io/tutorials/implementing-authentication-in-nuxtjs-app

In the tutorial, it show that
axios: {
baseURL: 'http://127.0.0.1:3333/api'
},

it is point to localhost, it is not a problem for my development,

but when come to deployment, how do I change the URL based on the browser URL,
if the system use in LAN, it will be 192.168.8.1:3333/api
if the system use at outside, it will be example.com:3333/api

How do I achieve that?

anneau

anneau posted a new question

axios-module •

Cannot proxy localhost:3000 to localhost:3001

Hi, I use nuxt.js and nuxt/axios-module.

I run nuxt.js on Docker Container by port 3000.
Also run rails app on Docker Container by port 3001.

Bad has error…

ERROR [HPM] Error occurred while trying to proxy request /api/v1/products from localhost:3000 to http://localhost:3001 (ECONNREFUSED) (https://nodejs.org/api/errors.html#errors_common_system_errors)

my nuxt.config.js

** Nuxt.js modules
  */
  modules: ['@nuxtjs/axios', '@nuxtjs/bulma', '@nuxtjs/font-awesome'],
  /*
  ** Axios module configuration
  */
  axios: {
    // See https://github.com/nuxt-community/axios-module#options
    proxy: true,
  },

  proxy: {
    '/api/': { target: 'http://localhost:3001', changeOrigin: true },
  },
filipkisic

filipkisic posted a new question

axios-module •

Axios self signed certificate error in asyncData and nuxtServerInit

I am working on a project and I am using nuxt for it. API calls are being made to node.js server over https, and since everything is in my local development, I am using self signed certificates.

When I try to make axios call from asyncData, I receive

ERROR  self signed certificate                                                                                                                                           
at TLSSocket.onConnectSecure (_tls_wrap.js:1049:34)
at TLSSocket.emit (events.js:182:13)
at TLSSocket.EventEmitter.emit (domain.js:442:20)
at TLSSocket._finishInit (_tls_wrap.js:631:8)`

Same error shows when i try to make axios call from nuxtServerInit . Identical call made from methods and called with @click gets the data and works. Also, other calls in store actions also work without issues.

Is there a reason why this calls don't work, and also, is there a way to make axios calls as described above?

this doesn't work:

async asyncData(context) {
    let result = await context.app.$axios.$get("/item", {
      headers: {
       "x-auth": context.store.getters["login/getToken"]
  }
  });       
  console.log("item: ", result.item);
}

and this does work without problems:

methods: {
async getItem() {
try {
  let result = await this.$axios.$get("/item", {
    headers: {
      "x-auth": this.$store.getters["login/getToken"]
    }
  });      
  console.log("item : ", result.item);
  } catch (e) {
  console.log(e);
  }
 }
}

Thank you for help

papakay

papakay posted a new question

axios-module •

asyncData takes a longer time to return data.

Hi, I really want to commend the great work done on this package.

Please I have a page that takes over 20 seconds to load and that has been a great concern to me. The page is just a form but it gets the form data from an API endpoint. With the asyncData method, the page takes more than 20 seconds. I've also tested the endpoint to confirm if that was the problem, but the endpoint takes less than 0.7 second to return data. This is what my async data looks like

async asyncData({ $axios }) {
    try {
      const response = await $axios.$get("v1/account/me");
      return {
        user: response.data.user
      };
    } catch (e) {
      return {
        user: null
      };
    }
  },

Please what are mine doing wrong?

matamune94

matamune94 posted a new question

axios-module •

share a method of use axios globally standard for nuxtjs?

i want use it for all components and pages and my config present :

~/plugins/axios

import axios from 'axios'

export default axios.create({
baseURL: 'http://127.0.0.1:3001/'
})

but with this way , i must import axios from '~/plugins/axios' in components and pages i want use something choise for like this

this.$axios.post('url',data).then(res=>{
// do something in here
}).catch({
// do something in here
})

and no need import more axios