Axios function not returning any values with js

Axios function not returning any values with js

Content Index :

Axios function not returning any values with js
Tag : javascript , By : uxn
Date : January 12 2021, 08:33 AM

Does that help I am using a function which uses axios. I want to be able to call this function and get the array I am trying to return back. Unfortunately I am getting back undefined. I don't know if I am just returning it wrong or if it has to do with axios taking time to make an api call. , The function returns a promise. You can call it like this:
filterItemsByRadius(userRadius, items).then(resp => {

No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Returning an Axios Promise from function

Tag : javascript , By : Sigtryggur
Date : March 29 2020, 07:55 AM
it should still fix some issue Your first example returns the original promise. Your second example returns a different promise, the one created by calling catch.
The critical differences between the two are:
return request
    .then(result => { console.log(result); return result; })
    .catch(error => { console.error(error); return Promise.reject(error); });
return request
    .then(result => { console.log(result); return result; })
    .catch(error => { console.error(error); throw error; });

Axios.get() inside a map function to get data for multiple objects returning promise object

Tag : javascript , By : Chris Hubbard
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further I have been having a problem with an axios fetch call inside of a returned object from a Array.map function. Whenever I return the response it returns a promise object to the array with the data I need but I can't seem to parse the promise object to get the data I need from it. When I console.log the response I get a regular object and not a promise. , As for approach
export const checkStreamerStatus = (streamers) => async (dispatch) {
    payload: {
      streamers: streamers.map(streamer => ({
        status: await getStatus(streamer)
async function appendWithStatus(streamer) {
  return {
    status: await getStatus(streamer);

export const checkStreamerStatus = (streamers) => async (dispatch) => {
    const streamersWithStatus = await Promise.all(streamers.map(appendWithStatus));
      payload: {
        streamers: streamersWithStatus,

Returning Error Values Through Axios/Express To React App

Tag : javascript , By : Meg
Date : March 29 2020, 07:55 AM
this one helps. See https://github.com/axios/axios#handling-errors
You can access the response by using err.response.data.message, not err.message.

Callback function in Axios returning error (using Vue, no jQuery)

Tag : javascript , By : tjh0001
Date : December 25 2020, 07:01 PM
should help you out here is a working fork with no errors : Codepen
the issue you had is that the this.word inside your then callback was not defined because you didn't bind the vue this inside it ...also you handled the response by using 2 thens so the first one was handling the response but it wasn't returning anything to the second one that's why response was undefined to fix this just use one then or return a value from one and chain it to the other then after it.... i would recommend removing the first one on your axi method and add the code inside it on the other then also like we said you have to bind then and you can do that by replacing :
  var r = response.data[0].phonetic;
  this.word[x] = r;
then((response) => {
  var r = response.data[0].phonetic;
  this.word[x] = r;

axios async await function not returning validation errors

Tag : ruby-on-rails , By : drbillll
Date : March 29 2020, 07:55 AM
Related Posts Related QUESTIONS :
  • Is there value in propTypeing repeat required properties at every level of nested components?
  • Call function if variable does not exist in a filter
  • localStorage value doesn't get updated automatically
  • React not updating state with setState correctly inside promises
  • Direct native JavaScript or jQuery method to get containing block of an element
  • Dynamic JSON object to Html Table
  • How to send Id and file to same controller?
  • How to Make a jQuery Table Cell(td) clickable to Run a Function?
  • Prevent the duplicate function onchange event jQuery
  • Reactjs Input Upload doesn't return local URL
  • An unexpected 'StartObject' node was found when reading from the JSON reader. A 'PrimitiveValue' node was expected
  • How to filter a JSON Array, with an eventListener input value at keyup
  • How to separate the different properties of filter in css?
  • Why dont work change event of bootstrap input spinner?
  • How to hide overflow text content in react
  • Is there another way to write line 6
  • Cypress - how to find by text content?
  • How to setstate for the dynamic checkboxes in a loop in react?
  • Is display:none safe?
  • How to create a form to change part of a href url of a button?
  • Put many function inside function in Javascript
  • how to exit from loop after a ajax call
  • Do Angular Reactive Form Validator.min/max check Perform Type Conversions before checking the value?
  • How to Replace Text Within Script Tags Using JQuery
  • add variable to object if not undefined using short-hand
  • How can I effectively curve my items inside a list?
  • Add new record Keyboard Shortcut on Kendo Grid Mvc
  • Time and Date running on page
  • Looping through page links puppeteer doesn't return values from the newly loaded page
  • Problem with Navigator.geoLocation.getCurrentPosition not working
  • Trying to change the id of an element with Javascript
  • Embedded Schema Inserting Blank in Meteor using Collection2
  • avoid useEffect to render at first load?
  • Why is this CSS transition only working correctly on the some clicks? How to solve it?
  • Interpolated values does not reflect the latest values in an Angular app
  • Javascript classes define attribute in constructor or outside the class
  • How to block scroll event passing through to iframe until iframe is active?
  • What is the purpose of "constructor" method in javascript?
  • Stencil JS not working with non-default imports
  • Are frameworks misleadingly named for marketing purposes?
  • React <Redirect> after transition not working
  • How to send multiple parameters in a function using EJS
  • React conditional style on custom click
  • Push a block of information to an array X times based on an external variable
  • How do I populate dropdown with names, and values (numeric ids)?
  • How to apply styling to elements created with .insertAdjacentHtml method
  • Positioning key:value of an object
  • Referencing DOM Elements with React Hooks
  • TypeError: Method "getRange" of null when using multiple scripts (Libraries) in Google scripts
  • Why can't I check if an environment variable is undefined?
  • Is there a way to find what parts are the same between two strings?
  • Every change done with magicscroll and greensock get reset when I hit the bottom of the page
  • Fix a 'Cannot read property handleClick of undefined error' (and issues related to deleting an item from the DOM)
  • Answer to message if sent within a period of time
  • Enabling a button based on selected values
  • Get All possible matches between forward slashes
  • get the CSS maxWidth value of the parent javascript
  • Async function returning existing array as undefined
  • Using drop-down list to change multiple values in separate table cells
  • How to remove nested empty objects in JavaScript?
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com