Questions tagged [axios]

0

votes
1

answer
20

Views

How to avoid sending multiple duplicate AJAX requests in axios

Is it possible to automatically throttle all requests going to a particular list of endpoints using axios? Perhaps using axios interceptor? Currently I throttle the user action that sends the axios request, but the problem with that is that I have to write this everywhere I have a user action that r...
ManavM
1

votes
2

answer
940

Views

Moxios - TypeError: Cannot read property 'adapter' of undefined

Trying to test axios calls and trying the moxios package. 'axios': '^0.16.2', 'moxios': '^0.4.0', Found here: https://github.com/axios/moxios Following there example, but my test errors out on the moxios.install() line: import axios from 'axios' import moxios from 'moxios' import sinon from 'sinon'...
Leon Gaban
1

votes
1

answer
486

Views

axios interceptors integration with vuejs custom components for displaying error messages in a generic way

Let's suppose we have the following piece of code axios.interceptors.response.use(function (response) { return response; }, function (error) { if (error.response.status === 400) { if (error.response.data.type === 'fieldsValidationErrors') { openModal(modal.validationsFailedInfo); } else { openModal...
tzortzik
1

votes
2

answer
4.7k

Views

Check axios request url before sending

API requests are failing because the URL generated by Axios is incorrect due to my config. I know what the request url is suppose to look like, so I want to see the request url Axios generates. I can point Axios to my local server and see the requests there, but I want to debug this on the client. I...
Dan
1

votes
2

answer
831

Views

How do I properly push JSON array onto existing data array in Vue JS on a Axios response?

I think this is a general Javascipt question however I am working in Vue Js, Laravel & Axios. How do I push one JSON array into another JSON array? My problem is that when I push the secondary array into the primary array it is nested (see screenshot). I need it as part of the same array. Is th...
Jquestions
1

votes
1

answer
215

Views

Django rest-auth Token authentication

I'm trying to use axios to get information from the /rest-auth/user/ page. This is my function: export const fetchUser = () => { const token = localStorage.getItem('token'); return dispatch => { dispatch(fetchUserPending()); axios.get('http://localhost:8000/api/v1/rest-auth/user/', {headers: { 'auth...
peter176
1

votes
1

answer
41

Views

Unable to render react-native Component after fetching data from firebase

I am able to fetch data from the Firebase API. I am able to set the state into the data received (I can see in Console). But when I am unable to render a Component (passing props as fetched data). Here' my code: class NewMeals extends Component { constructor(props){ super(props); this.state= { data:...
Saumay Paul
1

votes
3

answer
320

Views

Axios request receiving a CORS error only when inside a callback/async function

I'm using VueJS for an app I am building. The server I have is written in Golang and has been set to accept CORS. In the app, in one of my components, searchBar, I have set it to fetch some data before it is created. var searchBar = { prop: [...], data: function() { return { ... }; }, beforeCreate:...
1

votes
2

answer
30

Views

has been blocked by CORS policy by using axios and fetch in react [duplicate]

This question already has an answer here: Axios having CORS issue 2 answers I'm trying to do a post request of a server but keep getting a CORS error using axios and fetch in React. the code: fetch('https://api/entries', { mode: 'no-cors', method: 'post', headers: { 'Content-Type':'application/oct...
Jorge pino
0

votes
1

answer
15

Views

Cannot Set cookie in axios response

I'm using the Nuxt.js to develop the website, I want to call API and put the results to the cookie on server side I will do this part in Nuxt.js middleware. But I can call API, I can set the cookies, but I CANNOT set cookie using the API response. Call API import axios from 'axios' export default ({...
Pete
0

votes
0

answer
5

Views

Imgur api axios request blocked by CORB

Everything in my project works as it should. I get the 'request' answer (200 OK) but I still get this warning; ('Cross-Origin Read Blocking (CORB) blocked cross-origin response https://api.imgur.com/3/upload with MIME type application / json. See https://www.chromestatus.com/feature/5629709824032768...
Ibrahim Yolbir
0

votes
0

answer
42

Views

Why is GET date correct but incorrect in POST?

Using Reactjs with Axios to post/get to a dotnetcore webapi. Axios GET api call to retrieve a list of datetimesUTC 1a. Response datetimeUTCs are clearly correct in console/display. Axios GET api call passes in the selected datetimeUTC 2a. The API clearly receives the correct UTC datetime Axios POST...
DateTimeSucks
9

votes
1

answer
90

Views

Expecting an error with axios-mock-adapter

I am trying to test an axios get request with axios-mock-adapter, such that an error is thrown given a status that does not equal 200. However, when I execute the test (see api.test.js), I get the following message: Error: expect(function).toThrowError(undefined) Expected the function to throw an er...
Jimmy
0

votes
1

answer
19

Views

How to save username and password for login in external link in react

i make a login page , after login must redirect to external link , how to save user and pass in login ? i need after click in button login my users logged in external website i use 'axios': '^0.18.0','react': '^16.8.5', 'react-dom': '^16.8.5', 'react-router': '^5.0.0', 'react-router-dom': '^5.0.0...
soodeh
1

votes
1

answer
1.8k

Views

Send a POST request via Axios to a Firebase Cloud Function

I try to send a simple request to a Firebase function, but I get the same error every time... Apparently, the Firebase function does not receive the data I want to transmit from the Axios request. This is the Firebase function : [...] // Some imports exports.completeProfile = functions.https.onReque...
Jean
1

votes
1

answer
31

Views

React + Axios - Data loaded able to console log but not showing up in DOM?

I have a problem with my simple React App. I'm able to connect to an API using Axios and can console log. However, I'm not able to output the data inside the DOM. it's empty why? import React, { Component } from 'react'; import axios from 'axios'; class App extends Component { state = { fragrances...
Nino Merdzanovic
1

votes
1

answer
69

Views

Laravel PATCH Request doesn't read Axios form data

I'm trying to send a Axios PATCH request to Laravel 5.6 api. My request contains a FormData. Laravel's api endpoint doesn't read any of the sent data. ReactJS code let data = new FormData(); data.append('photo', this.state.photo); // append another data .... const headers = { 'Content-Type': 'multi...
Abeer Elhout
1

votes
2

answer
52

Views

Axios Vue.js Pass an array of objects from store.js to component

I am struggling with the Vue.js so i would like your help. I want to do something too simple but unfortunately without luck. In the store.js i have an axios fetch that return the data from the called API. My next step is to pass the object in the component. I succeed to do it using this.$store.dis...
Ioan Dimi
1

votes
1

answer
52

Views

The show method in laravel return the index method instead

I have an issue trying to use the show method in a resource controller in laravel 5.7. I'm working with VueJS and axios to http requests. The index method is called instead show method. I'm pass do the call with get method and the ID param. Routes: POST | products...
Andres Ruales
0

votes
1

answer
21

Views

React Axios Service Class

I am using axios to handle API calls in my React/Redux application. The token is set globally. Here are some examples: // Add Post export const addPost = postData => dispatch => { dispatch(clearErrors()); axios .post('/api/posts', postData) .then(res => dispatch({ type: ADD_POST, payload: res.data,...
drevival
0

votes
2

answer
17

Views

Flask send_file / send_from_directory returning 200 status code but not the file

I'm trying to send a file from my Flask app through send_file() or send_from_directory() without success. The request returns a response with status_code=200 but no file is being downloaded. I have verified the functions work as they return errors when the file or directory does not exist This is th...
dariuscosden
1

votes
0

answer
512

Views

I get a 503 response status whenever I try to make a POST request from my client

I recently created a server and deployed it to Heroku. It works fine in Postman and when testing out basic GET requests. But whenever I try to make POST request to it via Axios in my client, I am met with this error. In my back-end server, I enabled cors so that it could make cross-domain requests....
MountainSlayer
1

votes
0

answer
178

Views

multipart/mixed: with axios and reactjs for several json requests

I am trying to request multiple JSON requests for youtube api v3: The aim is to get the latest 25 videos uploaded from 5 different channels. https://www.googleapis.com/youtube/v3/search?part=snippet&channelId={CHANL000}&channelType=any&maxResults=25&order=date&key={XXXXX} https://www.googleapis.com/...
Santhosh Yedidi
1

votes
1

answer
80

Views

Vuex and Laravel 5: how to remove Tags from Articles

I have a small blog app that has Articles and Tags. Nothing fancy so far. Every Article can have many Tags. The Laravel backend delivers the data via API calls from Axios in the Vue Frontend. In the Laravel models Article has a method public function tags(){ return $this->belongsToMany('App\Tag'...
shopfreelancer
1

votes
0

answer
40

Views

Return places and addresses from Mapbox

I am using the mapbox geocoder to return points based on search input. I would like my user to be able to type in raw addresses (e.g. 123 Elm St.) in addition to names of places (e.g. Starbucks). My function that returns results is here: geocodeThis(query) { const { homePoint } = this.state const ac...
astrojams1
0

votes
0

answer
357

Views

cross domain with nuxtjs/axios

I want to call a api provided by another domain, follow the official document, this is part of the nuxt.config.js: modules: ['@nuxtjs/axios'], axios: { proxy: true, baseURL: 'http://localhost:8000/api', // prefix: '/api', // it not work credentials: true, }, proxy: { '/api/douban': { target: 'http...
daskyrk
1

votes
0

answer
334

Views

force-download with Django and Vue

I was trying use vue to download file from server when I director visit my backends API, it work well,and I can unzip my file normal. but when I try to download file by axios response, the file can not unzip,and also if I don't set link.download, the filename does not correct.like that here is...
鲁成wolf
1

votes
0

answer
328

Views

Excel download from Asp.Net Web API using Axios post method

I have an action which returns excel file. [HttpPost] public async Task Export([FromBody] QueryParameters qp) { var stream = _service.GetExcel(qp); var exportFileName = 'MyExcel'; return File(stream, 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', exportFileName)...
Parashuram
1

votes
0

answer
242

Views

How to navigate to a url with different 'id' property using axios library in redux

I am working on a redux project where I have a list of posts(like Blog Post) and each post has an unique id.Also,I have a different component which displays the detail of a particular post(I have named it Post_Detail component). So what I want to do is when I click on a particular post from the list...
pranami
1

votes
1

answer
493

Views

Axios ajax call returns sometimes html

In Vue.js 2 I'm making an ajax call with axios. It's all working fine. However when I go one page further and then go back to the page where the ajax call is made, the ajax call suddenly returns html so no json objects. What could be going on here? When I test the url in postman I receive json back...
Jenssen
1

votes
0

answer
322

Views

Getting axios posted data with a laravel request?

I post data via axios: axios.post('/api/test', { postId: 1, userId: 1, }) Then on the Laravel backend I get the request via: use Illuminate\Http\Request; .... public function store(Request $request) { dd($request->all()); } But I get the error: Uncaught ErrorException: Array to string conversion I h...
panthro
1

votes
0

answer
192

Views

Laravel api config custom validation to not crash

So I have laravel configured as api and as seperate app I have vue. In Laravel I have cors set up: 'supportsCredentials' => false, 'allowedOrigins' => ['*'], 'allowedHeaders' => ['Content-Type', 'X-Requested-With'], 'allowedMethods' => ['*'], // ex: ['GET', 'POST', 'PUT', 'DELETE'] 'exposedHeaders'...
Przemek Wojtas
1

votes
1

answer
230

Views

Eliminate race condition in `axios` nested calls

What is a good way to eliminate race conditions in API requests with axios? I have this: rest.outerCall(id).then(results => { let {data} = results; for (let i = 0; i < data.length; i++) { rest.innerCall(data[i].id).then(innerData => { data[i].name = innerData.name; }); } this.setState({ results: res...
Origin
1

votes
0

answer
303

Views

REST error 400 “Access Denied” on IE11

We're facing the problem with REST Api on Internet Exploler. Evety single request is blocked by the browser. The same requests works correctly on other modern browsers. When we add our our application to trusted pages, it starts working. It is only possible solution? On api.domain.com we have Slimp...
Caffrey
1

votes
0

answer
168

Views

Unable to add authorisation in headers to a GET request using axios

Recently, I needed to access the API gateway in AWS using my localhost environment. I am using axios to do a GET request on the API gateway in AWS. The GET request requires an Authorization header in its request. I used the following piece of the code axios({ method: 'GET', url: ROOT_URL+'/users/me'...
shubhamagiwal92
1

votes
1

answer
267

Views

RxJs and redux-observable. Append value when ajax succeed or failed

I have the following epic: export const changeTeamSubscriptionPlan = (braintreePlanId: string) => ({ type: CHANGE_TEAM_SUBSCRIPTION_PLAN, braintreePlanId, }); export const changeTeamSubscriptionPlanEpic = (action$: any, store: Store) => action$.ofType(CHANGE_TEAM_SUBSCRIPTION_PLAN) .mergeMap(({ brai...
Tomasz Mularczyk
1

votes
0

answer
217

Views

unable to post values to api using axios in redux

I am trying to post data from a redux-form to an api server using axios.My action creator for posting the data looks like this: //Action creator for submitting edited post export function submitEditedPost(values, callback) { const request = axios.post(`${API}/posts`, {headers}, {values}); return dis...
pranami
1

votes
0

answer
398

Views

VueJS Authentication with Django REST Key

I can retrieve a key after logging in through my Django REST API, but then I am wondering how I should store that key. I'm not really using Django, but I imagine I have to store the cookie myself then or something. I'm using Axios for VueJS to interact with the API. I am using django rest auth to ge...
Florin
1

votes
1

answer
851

Views

Reactjs Nodejs file upload ftp via axios

I am trying to upload file using React Dropzone on ftp with Reactjs + AXIOS at front end, Nodejs + connect-multiparty at back end. The problem is when I am sending file via front end using AXIOS, I am not getting the file at server in request. My code to upload file using react-axios is let data = n...
Shahid Peerzade
1

votes
1

answer
370

Views

Node.js Axios request

How to pass this Python code to Node.js code? rc = requests.get(url).json() auth_url = rc['a'] pin_url = rc['b'] client_id = rc['c'] As I can pass this same code to Node.Js (ES6) I have tried to use the module of https://github.com/request/request and that of https://github.com/axios/axios but thes...
Jeisson Florez

View additional questions