Questions tagged [axios]

Axios is a Promise-based HTTP client for JavaScript which can be used in your front-end application and in your Node.js backend.

Promise based HTTP client for the browser and Node.js, available on Github.

Features

  • Make XMLHttpRequest from the browser
  • Make HTTP requests from Node.js
  • Supports the Promise API
  • Intercept request and response
  • Transform request and response data
  • Automatic transforms for JSON data
  • Client side support for protecting against XSRF

Installation

Using npm:

npm install axios

Using bower:

bower install axios

Using yarn:

yarn add axios

Using jsDelivr CDN:

<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>

Using unpkg CDN:

<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
24271 questions
23
votes
4 answers

Cancel previous request using axios with vue.js

I am using axios and vue.js.I have google it,and check the axios docs but still cannot understand how to do it.
Ready Dev
  • 537
  • 3
  • 5
  • 11
23
votes
1 answer

Vue-Router Passing Data with Props

I am having a hard time passing props using Vue-Router. I seem to not be able to access the props when I bring them into the next view. This is my methods object: methods: { submitForm() { let self = this; axios({ method:…
lnamba
  • 1,681
  • 3
  • 18
  • 26
23
votes
1 answer

Axios posts as JSON object, how to change

As the title states, when you do a axios.post('/user', { firstName: 'Fred', lastName: 'Flintstone' }) .then(function (response) { console.log(response); }) .catch(function (error) { console.log(error); }); The data will…
A. L
  • 11,695
  • 23
  • 85
  • 163
23
votes
1 answer

Axios CORS issue with Github oauth Not getting access token

I have created 2 routes on my React-Redux app. I have added github applications settings with homepage and callback URL already. 1. When you hit this route : https://reduxapp.herokuapp.com/signin You click on Github login button, ==>…
STEEL
  • 8,955
  • 9
  • 67
  • 89
22
votes
1 answer

Cannot read property 'mockResolvedValue' of undefined

I'm getting an error mocking my api call TypeError: Cannot read property 'mockResolvedValue" of undefined and cannot figure out why. I'm utilizing jest to test my api fetch call function. This is my function I'm exporting: //file amData.jsx const…
pt2t
  • 431
  • 1
  • 7
  • 16
22
votes
5 answers

Cannot find module 'axios'

I am coding a small program for Firebase Functions, using node.js. I always install my node modules using npm and i also installed axios using npm only. However when I do firebase deploy I get this error: This is my package-lock.json { …
Asaak
  • 477
  • 1
  • 6
  • 15
22
votes
3 answers

How to rethrow errors of HttpService call with NestJS?

I am using NestJS to essentially proxy a request to another api using the HttpService (an observable wrapped Axios library). For example: return this.httpService.post(...) .pipe( map(response => response.data), ); This works properly when…
Chaz
  • 3,232
  • 5
  • 19
  • 12
22
votes
7 answers

Passing path parameters in axios

I am using Axios with NodeJs and trying to pass path parameters in axios.get() method. For example, if URL is url = '/fetch/{date}', I want to replace {date} with the actual date while calling axios.get(url). I went through the source code on Github…
Saheb
  • 1,392
  • 3
  • 13
  • 33
22
votes
3 answers

How do you verify that a request was made with axios-mock-adapter?

I am using https://github.com/ctimmerm/axios-mock-adapter I would like to know how can I verify that an endpoint was actually called by the system under test. In this example: var axios = require('axios'); var MockAdapter =…
Daryn
  • 3,394
  • 5
  • 30
  • 41
22
votes
3 answers

Axios 400 error request call then instead of catch

I have this function: add(App, Params, Callback){ var self = this; var Data = self.process_fields(Params) self.$http.post( paths.api + '/app/' + App.Permalink, new URLSearchParams(Data) ).then(function (error,…
50l3r
  • 1,549
  • 4
  • 16
  • 27
22
votes
4 answers

Handling async request with React, Redux and Axios?

I am new to React JS and Redux and it has been too overwhelming to get going. I am trying to make a POST request using Axios, but I am unable to make it. May be I am missing something in the container file. Below is the code. Check plnkr Update: I…
jackD
  • 801
  • 2
  • 8
  • 26
22
votes
2 answers

process Axios POST in PHP

I want to send a POST request to my PHP file to handle it and store the data in the database.. I'm pretty stuck at it since $_POST stays empty whatever I try.. Can someone help me sending a post request and help me how to handle it ? My axios…
Laurens Mäkel
  • 815
  • 2
  • 12
  • 29
22
votes
1 answer

Axios ReactJS - Cannot read property 'setState' of undefined

I am getting an error "TypeError: Cannot read property 'setState' of undefined" while doing a simple thing in ReactJS. I am trying to use axios to fill input with response data. So far without success. I am very new to both axios and ReactJs so it…
rluks
  • 2,762
  • 8
  • 38
  • 56
22
votes
1 answer

Axios spread() with unknown number of callback parameters

I need to process an unknown number of AJAX requests (1 or more) with axios, and I am not sure how to handle the response. I want something along the lines of: let urlArray = [] // unknown # of urls (1 or…
treeblah
  • 1,205
  • 2
  • 11
  • 26
22
votes
1 answer

How to use axios / AJAX with redux-thunk

Im using axios inside my action. I need to know if this is the right way to do it or not. actions/index.js ==> import axios from 'axios'; import types from './actionTypes' const APY_KEY = '2925805fa0bcb3f3df21bb0451f0358f'; const API_URL =…
STEEL
  • 8,955
  • 9
  • 67
  • 89