Questions tagged [axios]

Axios, a JavaScript-based Promise-driven HTTP client, serves as an excellent tool for both front-end and Node.js back-end development in any application.

I need to know how to use Axios to fetch data from multiple sources at the same time without any risk of the

Trying to initiate multiple axios operations simultaneously to fetch data from various sources at once using a loop leads to the received data getting intermingled and corrupted. Even creating distinct axios instances for each data source doesn't seem to ...

Tips for sending a request from a Nuxt.js client through a Nuxt.js server and successfully receiving the response on the client side

I am currently working on a Vue.js application that operates solely on the frontend with no server involved. The app sends multiple requests to various APIs, resulting in its complexity increasing over time. Unfortunately, some of these APIs pose problems ...

delivering axios response to display the page

I have a code snippet that requests data from an external API using axios and I want to incorporate the response into my rendered page. Here is my code: //Snippet from my controller required in main routes exports.recordBySlug = async (req, res, next) =&g ...

Upon triggering a GET request to the URL "http://localhost:3000/search", a "404 (Not Found)" error response was received. Interestingly

Can Someone assist me please? I'm having trouble creating a website similar to YouTube and encountering the following error: GET http://localhost:3000/search 404 (Not Found) Uncaught (in promise) Error: Request failed with status code 404 at createError ( ...

Tips for managing data received from an Axios post request

I have a setup with a react frontend and node.js backend. Currently, I am successfully sending a POST request using axios: const [logins, setLogins] = useState({}); function updateLogins(e) { setLogins({...logins, [e.target.name]:e.target.value} ...

Enjoy the seamless integration of SPA Vue frontend with backend Laravel 7 using Sanctum for

Having trouble with my Vue and Laravel Spa setup using Sanctum. When sending requests through axios, I keep getting a status of 204. When trying to retrieve user information, I'm getting an Unauthenticated error message. Not sure what's going wro ...

A guide on extracting targeted data from an axios call in Reactjs

Looking for some assistance. I have a React app where I am sending a 'get' request to an NFL API using axios, and then displaying the response on my webpage. My goal is to only display players who hold the positions of QB, RB, or WR. I don' ...

Attempting to download an image through an axios fetch call

There is an issue I am facing while trying to retrieve an image from the website www.thispersondoesnotexit.com. function getImage() { axios({ method: 'get', url: 'https://www.thispersondoesnotexist.com/image' }).then(res => { ...

axios: prevent automatic sorting of objects according to keys

When using axios, I am receiving an API response. To send the sorted API response based on name, I use the following endpoint: http://localhost:8000/api/ingredients/ordering=name The actual object received from my server looks like this: { 2:{"id":2 ...

Looking for precise information within a Vue b-table by fetching data from an Axios API

My b-table is filled with data from an API hit through Swagger UI, and since there's a large amount of data, I need the search button at the center top of the page to work properly when inputting store code or branch. https://i.stack.imgur.com/l90Zx.p ...

Unable to utilize the fetch method in Node.js for sending the API request

I am currently using fetch to send a POST request and retrieve data from an API on the server side (using nextjs 13 + node 18). Interestingly, I can successfully retrieve the data using postman and axios, but not with fetch. Below is the snippet of code ...

The autonomous APIService requires access to either redux or the NextJS context in order to retrieve the token

Within my NextJS Application, I have a dedicated APIService.js file that serves various purposes, with the primary function being to set the BASE_URL and handle user authentication (checking for a token in either cookies or headers and dispatching it into ...

I'm having trouble adding headers to my axios post request. The post route functions correctly in Postman but does not work when using axios. Can anyone

Implementing JWT for protecting a post route in my nodejs, express, react application has been quite a challenge. While testing with postman and adding the JWT token to the headers works flawlessly to add users to the database, I encounter a 401 response ( ...

Axios AJAX request failing to pass parameter

Vuejs is my go-to frontend framework for building projects. When creating a component called ('TimeCapsy.vue'), I initiate an AJAX call to the backend in this manner: created: function () { if (verify.verify_login()) { let tok ...

Retrieve an uninitialized variable in Laravel using axios.post method within the Vue.js module

Hello partners! I'm collaborating with stackOverflow to develop a module using Laravel for the backend and Vue.js for the frontend. Currently, I am facing an issue where the controller is not receiving values from the form when creating a new entity. ...

Avoid using cookies for tracking purposes

I've set up basic authentication, which is working fine in my localhost environment. However, when I try to run the same setup in production, the registration process works but the cookie isn't getting assigned to the client site. Client side: functions ...

Axios encounters a problem: Unable to access the property '$get' as it is undefined

Find the code on github: https://github.com/aurora10/amazone-clone.git Attempting to use Axios to communicate with an API is resulting in the following error: The console shows a NUXT SSR error: TypeError: Cannot read property '$get' of undefined at asy ...

Repeated parameters when making a second login request with axios and sending data in url-encoded format

Implementing token-based authentication and sending urlencoded data via axios. Passing the user and password to the axios function with all parameters set as per documentation. import axios from 'axios' const params = new URLSearchParams() param ...

What is the best way to send an object array from an express function to be displayed on the frontend?

//search.js file import axios from "axios"; export function storeInput(input, callback) { //input = document.getElementById("a").value; let result = []; console.log(input); if (!callback) return; axios.post("ht ...

Utilize the get method to showcase data in a material UI table for a React application

Just starting out with React. Managed to create a table component with hard-coded data. However, I now have all the data stored in table.json. Can someone guide me on how to fetch values from table.json using an axios get request an ...

Types of Axios responses vary depending on their status codes

I am looking to create a specific type for axios responses based on the status code: types: type SuccessfulResponseData = { users: .... }; interface SuccessfulResponse extends AxiosResponse<SuccessfulResponseData, any> { status: 200; } ty ...

Encountering the error message "Uncaught Error: Objects are not valid as a React child" even though I am not passing objects as children in my React component

My current challenge involves mapping an array of objects, which I retrieved from an axios.get request and then passing them as children to React components. The error message that's causing trouble for me reads as follows: An Error occurred: Objects ...

`The steps to retrieve XML response data from an API request`

When using axios to make an API request, how can I receive data in XML format? For example: axios.get(/* URL */).then(response => {/* How do I retrieve the XML data? */}).catch(err => {/* result */}); ...

Different ways to separate an axios call into a distinct method with vuex and typescript

I have been working on organizing my code in Vuex actions to improve readability and efficiency. Specifically, I want to extract the axios call into its own method, but I haven't been successful so far. Below is a snippet of my code: async updateProfile({ ...

The CORS policy has blocked the 'Access-Control-Allow-Origin' header

My expertise lies in creating API, BackEnd, and Frontend websites. For the API, I utilize Express, while for the BackEnd - FrontEnd, I rely on ReactJs. During local testing, everything functions as expected. However, upon deployment to the server, error ...

Troubleshooting a connection issue between Laravel and Next.js when calling axios

My current setup involves using Laravel for the backend and NextJs for the frontend. When I attempt to submit the form, I encounter an issue. The server responds with the following error message: error I have verified that the csrf token is correctly obt ...

Is it possible to capture and generate an AxiosPromise inside a function?

I am looking to make a change in a function that currently returns an AxiosPromise. Here is the existing code: example(){ return api.get(url); } The api.get call returns an object of type AxiosPromise<any>. I would like to modify this function so ...

Leveraging OnMounted and Axios Requests in Pinia

I am currently developing a website that showcases a range of products with dedicated product pages. However, I am facing challenges in determining the optimal sequence for loading data. While I could make an axios call and pass the data as a prop to subse ...

What is the best way to upload a file and data simultaneously using Axios?

I'm currently facing an issue with posting data in a Vue application. Specifically, I am struggling with incorporating an image file input within the form. While most resources suggest sending the file separately or alongside other files,[1][2] What ...

Making an Axios request within a React Native application

I am struggling to understand the meaning of these errors. Below is the code for my component: import React, { Component } from 'react'; import { Text, View } from 'react-native'; import axios from 'axios'; class AlbumList extends Component { compone ...

Issues with React's useState hook not updating properly

As a React beginner, I am facing an issue with my input field filtering functionality. The problem arises when the results are filtered and rendered, as it seems to be ignoring the last character of the input value. For instance: If I type in "s", nothing ...

Tips for maintaining data in a React component across re-renders?

Currently, I am working on creating a basic axios call to communicate with a nodejs server from a react application in order to retrieve products stored in a mongoose schema model. The issue I am facing is that when the page initially loads, I can successf ...

Exploring Nuxt.js: A guide to server-side caching of axios calls for universal client access

I am currently working on a project using Vue and Nuxt.js. I am wondering if there is a way to cache an axios web service call for all clients. Specifically, I need to retrieve currency reference data and it seems inefficient for every client to make this ...

I am currently in the process of cross-referencing the tags that have been retrieved with those that have been selected or created. If a tag does not exist

I have a collection of tags in an object, and I want to dynamically add new tags before submitting the form. Despite using vue watch, it doesn't seem to be working for me. Here is the code snippet: data() { return { blog: { blog_title: ...

What is the process for accessing data of signed-in users?

I currently have a mobile app developed using the MERN stack that utilizes passportjs for user authentication and login (linked to a mongodb database via axios). However, I am facing an issue where I cannot associate the data/log entered by the user with t ...

What could be preventing React from successfully uploading images to the server?

My current project involves using React and Express on the backend, with Multer handling uploads. While my server side functions correctly when testing with Postman, I am encountering unexpected results when trying to upload an image from React. Despite su ...

Encountering a Persian query issue while using fetch or axios headers in Next.js error

As a developer using next.js, I am facing an issue with my code. I run a blog and need to search for a keyword in the titles of my posts. This excerpt shows part of my code: const [result, setresult] = useState([]); const [keyword, setkeyword] = useState ...

Having difficulty showing an image in the navigation provided via useContext()

The image is successfully displaying in the Profile.js screen and other areas. However, when attempting to pass the image via useContext() to display in Navigation.js, it shows as src(unknown). What could be causing this issue? https://i.stack.imgur.com/w ...

When using Axios to GET from a local PHP file, it only retrieves the code instead of running

I've run into an issue accessing the API as it has CORS disabled, requiring me to make requests on the server side. Currently, I'm using React and Axios to send a GET request to a local php file that should trigger cURL execution. However, instead of execu ...

Receiving a response code of 400 after making a POST request with

I'm facing an issue with my dotnet core webapi backend and React TypeScript frontend. When I try to create a user through one of the endpoints, I keep getting 400 bad request errors in the browser console. Upon inspecting the network tab, I found that it's ...

The Vue data retrieved from an API using onMounted() is not initially showing up in the DOM. However, it magically appears after I make changes to the template

Hello and thank you to those taking the time to read this. I am new to Vue, so I may be overlooking something obvious here, but after being stuck for several days, I am reaching out for help. In my SFC file, I have an onMounted function fetching data from ...

Encoding URLs for LoopBack applications

I am experiencing an issue with the filter I have: { "fields": {"goal":true,"amountPledged": true,"title": true},"where": {"title": {"like":`%${this.state.searchText}%`}} } The this.state.searchText value is bio. According to my understanding, it should ...

I'm having trouble jotting down notes in the TextFields

I'm currently facing an issue when trying to add a new user to my database using the axios post method. I have created a form with Material UI, and although there are no console errors or browser issues, I am unable to input text into the TextFields. Prio ...

Current CORS complications persisting with Vue 3, Axios, and ASP.NET Core Web API backend interaction

I am puzzled. While running my .net core server and loading the vue project in the same file, I encounter partial success. However, when I start testing the axios/fetch requests, the test project fails in other ways. My CORS policy is set to be very lenie ...

SWR NextJS error remains unhandled despite being thrown

I'm struggling to manage errors thrown in my SWR fetcher. Currently, whenever an error is thrown, my app stops working and I see an "Unhandled Runtime Error". What I've been doing is throwing the error inside the fetcher function. Here's th ...

React is unable to assign a class field beyond the scope of axios

class App extends React.Component { app: Application; ... componentDidMound() { axios.get(…).then(res => { this.app.currentUser = res.data.data; // setting value inside lambda function. console.log(this.app.currentUser); // ...

Exploring Nested JSON Objects with React and Axios

I am exploring the CryptoCompare API to retrieve cryptocurrency data. As a beginner with React, I have successfully used Axios for AJAX requests. However, I am facing challenges in accessing specific JSON elements. To view the JSON data structure, you can ...

Encountering an issue with Vue JS axios request and filter: the function this.XX.filter is not operational

I am encountering challenges while trying to implement a basic search feature on a JSON file obtained through an API. Each component works independently: I can successfully retrieve data from the API, perform searches on non-API data, and even search cert ...

Utilizing Axios for Submitting Form Data: A Step-by-Step Guide

Currently, I am in the process of developing a project that consists of a springboot backend and Vue frontend. At this point, I have successfully managed to retrieve a list of products from my database using GET requests. While I can display this list on a ...

If the status is 400, Xhr does not log the response

I have implemented a basic login route in express: //login router.post('/login',async (req,res) => { try{ const user = await User.findOne({username: req.body.username}); console.log(user); if (!user) { ...

The server-side is not receiving any data from Axios FormData

I am looking to efficiently transfer data from my blade.php file using axios (along with vue) to my backend. Inside blade.php function() { const fd = new FormData(); fd.append('a','b') axios.post('...', formd:fd); } Inside Controller ...

The geocoder-autocomplete feature in ReactJS is now experiencing a sudden Network Error in Firefox

I followed the tutorial provided by HERE and successfully implemented the solution for street address validation using ReactJS and HERE geocoder autocomplete. Everything was working fine on Firefox and Chrome until a few weeks ago when it suddenly stopped ...

Exploring the power of V-for with checkboxes in VueJS

One issue I am facing is related to triggering my save method only when a checkbox is selected or true in Vue JS. I have no problem listing values and saving them to the database using axios, Vue JS, and Spring Boot. However, every time I click the checkbo ...

Tips for obtaining accurate response from axios

When utilizing axios, I receive my query response in the format of response.data.response.object. Is there a way to access the answer directly without going through response.data first? ...

Having trouble sending `req.params` through http-proxy-middleware in a NodeJS/Express application?

I'm still getting the hang of Node, and I've run into an issue with passing request parameters using http-proxy-middleware. Every time I try, I keep getting a 404 error. This is my express listener setup: app.put("/api/markets/:id",()=>{..c ...

The login method does not pause for the dispatch action to be completed before navigating to the next

Within the UserLogin component, there is a submit button that triggers the following method: methods: { login() { this.$store .dispatch("login", { email: this.email, password: this.password ...

Is it possible to conceal or encrypt JSON data or header information in HTTP requests and calls?

I am currently developing a full stack website with Flask, Vuejs and SQLite3. I have been using axios to make backend calls from the frontend. However, I noticed that when I make 'GET' requests using axios (Vuejs) to the backend on a particular route, all ...

Tips for managing REST API calls in separate files within a React JS project

Hey there, I'm currently diving into the world of react js and have been developing something that is working smoothly so far. However, I've noticed that my api calls are scattered throughout various components. This means that if I need to update the IP a ...

Struggling to retrieve data with arrow function in Vue

I'm currently learning Vue and facing an issue with fetching data from an API to my component. I have a service class that successfully retrieves data from the API, as the API itself is working fine. Here's the code snippet: import IReview from & ...

Upon sending a POST request to http://localhost:5000/getData, a 404 error (Not Found) was encountered while using axios

As a newcomer to react and node.js, I have set up a fake server running on port 5000 with an API (http://localhost:5000/getData) that contains a hardcoded array of objects. My goal is to add a new object to this API from my react frontend running on port 3 ...

example of reusing vue js component multiple times on a single page

Within my components, I am making an axios call. I have defined two of them with props that provide the URI for the axios call. export default { name: "CardData", props :['uri','suffixe' ,'label'], data : function (){ return { lab : this.l ...

Tips on managing a GET request sent using axios with special characters and accents

When constructing a web page using VUE.JS, a GET request is made with Axios. In the form fields, special characters and accents may be present depending on the user's input. For instance, if the surname entered in the form field is 'Ruíz' ...

Encountering Axios errors while executing API calls at a high frequency

Recently, I have been facing some challenges with making API calls from localhost using axios in a loop. While it works smoothly at times, most often I encounter errors like: cause: Error: connect ECONNREFUSED ::1:8000 at TCPConnectWrap.afterConnect ...

Guide for redirecting a Vue application to the login page when a 401 error occurs

When working with my Vue.js component, I encounter an issue with redirecting users to the login page on error 401. Here is the code snippet where the problem occurs: mounted() { this.getDataFromApi() .then(data => { this.events = data.data; th ...

The compatibility between V-model and TinyMCE is unreliable

I've been working on integrating Vuejs and TinyMCE, using the @tinymce/tinymce-vue package for the Vue integration. I followed all the instructions and everything seems to be functioning properly - I can write, insert images... everything except for the v- ...

Guide to sending a post request with parameters in nuxt.js

I am trying to fetch data using the fetch method in Nuxt/Axios to send a post request and retrieve specific category information: async fetch() { const res = await this.$axios.post( `https://example.com/art-admin/public/api/get_single_cat_data_an ...

What could be the reason behind the undefined axios cookie issue?

After successfully hitting an endpoint with Postman, I noticed that the value of req.headers.cookies is undefined when using axios. However, browser cookies are functioning correctly. In contrast, Postman requests show that the value of req.headers.cookie ...

Frontend Axios request fails to retrieve necessary data from MongoDB backend database

Reaching out to the backend to retrieve posts from a mongoDB database. Successful in postman but encountering a custom error on the frontend. Puzzled as to why it's not functioning properly. Utilizing Redux to fetch user information for ...

What is the best way to manage a promise's response?

I'm currently facing a situation where I need to create a petition to an endpoint and retrieve the URL of the backend that I intend to use. My setup involves a file with the API configuration where I instantiate axios. Previously, my approach was simple a ...

What are some ways to implement a pre-execution step, such as an interceptor, before Nextjs runs getStatic

When working with getStaticProps and getServerSideProps in Next.js, I need to intercept and add common header properties to all request calls that are executed server-side. axios.interceptors.request.use(function (config) { // Perform actions before ...

What is the best way to send a POST request using axios with both body and form data included at the

Is there a way to successfully send a post request using Axios that includes both body data and form data? I am having trouble getting the data to reach my route handler: axios({ method: 'POST', url: `${keys.SERVER_URL}/post/new-post/${i ...

API request was blocked due to the CORS policy

As I work on developing a web app using Vue.js, users must log in to receive an API key. My post request to the API through axios includes two parameters - a name and a password. However, upon form submission, persistent errors keep appearing: OPTIONS htt ...

I am unable to retrieve the value stored within a function

Below is the code snippet : let namesList = ref([]); const GetFormData = (payload) => { return new Promise((resolve, reject) => { api .get("api.php", { params: { search: payload } }) .then((response) => { data. ...

Retrieving information and implementing condition-based rendering using React's useEffect

I am currently developing a MERN stack application that retrieves information regarding college classes and presents it in a table format. The CoursesTable.js component is structured as follows: import React, { useState, useEffect } from 'react'; ...

Having trouble with implementing Nested routes in Vuejs?

main.js import Vue from "vue"; import App from "./App.vue"; import VueRouter from "vue-router"; import HelloWorld from "./components/HelloWorld"; import User from " ...