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
4
votes
1 answer

Get image from server and preview it on client

So i'm trying to get an image from a server and previewing it on the client, i can retrieve the image for now, but i don't know how to preview it on a web page asynchronously. axios.get(link,{responseType:'stream'}).then(img=>{ // What i have to do…
FrenchTechLead
  • 1,118
  • 3
  • 13
  • 20
4
votes
1 answer

Axios callback on GET for React

I am trying to display a loading spinner while the axios get request is going on and to do so I believe I need a callback from the request. I call the get request in componentDidMount() like so: componentDidMount() { …
erp
  • 2,950
  • 9
  • 45
  • 90
4
votes
2 answers

TypeError: Cannot set property 'posts' of undefined - Vuejs

I create SPA with VueJs and Laravel. Homepage i get all posts via api laravel and axio responsive had data object. But i can not update to posts property. Error in chrome debug tool: My code in Wellcome.vue import { mapGetters } from…
Nguyen Manh Linh
  • 689
  • 1
  • 6
  • 7
4
votes
1 answer

Cannot access correct this inside an axios callback

got a little mind-fart atm. I've managed to write following code, which downloads a JSON from url and displays it on the screen: export default class Appextends React.Component { constructor(props) { super(props); this.state = { data:…
H. Doe
  • 545
  • 2
  • 5
  • 12
4
votes
2 answers

Looping API calls with Axios and Promises

I'm using Axios to make API calls, and for one call I'd like to continue polling the API until I get a response. However, when I call this function something resolves the promise earlier than expected. I call the function here: componentDidMount()…
Toby
  • 12,743
  • 8
  • 43
  • 75
4
votes
2 answers

React.js render json response, co fetch or axios

I've been pulling my hair out too long and I can't focus anymore. I am trying to take the json from a url and just render it visually in the browser. It doesn't even need to be formatted, at least it doesn't until I get past this hurdle. I can get…
fearofmusic
  • 155
  • 1
  • 2
  • 9
4
votes
1 answer

Sending data in Laravel using Axios & Vue

I have been following the Stripe integration tutorial by Laracasts and it's become apparent to me that a lot has changed since Laravel 5.4 was released. I have been able to still find my way along but I have hit a bump trying to submit a payment…
Redback87
  • 47
  • 2
  • 7
4
votes
2 answers

axios cannot resolve state element react

I am fairly new to react and following a tutorial. The instructor is using axios to pull some data from a github api. Following is what he suggests as an onSubmit event handler: handleSubmit = (event) => { event.preventDefault(); …
Omkar
  • 2,274
  • 6
  • 21
  • 34
4
votes
1 answer

Spring Boot + React.js Axios: 403 Forbidden for HTTP POST calls

On my dev environment I have a BE built using Spring Boot and a FE built using React.js (Redux + Axios). Whenever I try to perform an HTTP POST using Axios I get 403 forbidden. HTTP GET calls work as expected and HTTP POST calls made from Postman…
Humble Student
  • 3,755
  • 4
  • 20
  • 35
4
votes
2 answers

Creating an instance of axios in Vue not working

I am using axios for AJAX in Vue. In the article written by You, he mentioned that we can set Vue.prototype.$http = axios and I can use this.$http in Vue instance. It works fine. However, if I want to create an axios instance to $http,…
PJCHENder
  • 5,570
  • 3
  • 18
  • 35
4
votes
1 answer

axios PUT call not working getting 415

I am trying to call another service from my express app using axios (also tried node-fetch) So, when I call the service using curl, soapui or swagger it works. curl -X PUT --header 'Content-Type: application/json' --header 'Accept: application/json'…
shresthaal
  • 675
  • 4
  • 13
  • 28
4
votes
1 answer

How to make synchronous API call request in react js

i am beginner to react js i am working on a small application which makes api requests frequently. So the problem i am facing is there is a page with form fields prefilled from the db, if the user makes changes to those fields i am posting the new…
Chaitanya Sairam
  • 121
  • 1
  • 2
  • 16
4
votes
1 answer

Unable to send credentials in CORS request

I have an application where the Vue front-end is on a different domain than the server. Specifically, Vue is located on localhost:8080 and the server is located on localhost:4000. During successful logins, the server responds with an HttpOnly cookie…
Ege Ersoz
  • 6,461
  • 8
  • 34
  • 53
4
votes
2 answers

How can I add data to the pending action?

I am using Axios, Redux and Redux Promise Middleware. I have the following action creator: return { type: 'FETCH_USERS', payload: axios.get('http://localhost:8080/users', { params: { …
Baz
  • 12,713
  • 38
  • 145
  • 268
4
votes
1 answer

Test a function that calls an API

I need to test the fetchData() function. I have been trying to follow this (and many other) tutorials and trying to get it to work with my function for the past 3 hours but no luck so far. I'd preferably want to do it another way anyway because I…
WillKre
  • 6,280
  • 6
  • 32
  • 62
1 2 3
99
100