#Issues with returning

16 messages · Page 1 of 1 (latest)

low drift

I am having an issue returning data from a table sent from a API

const weatherData = axios.get(`API`)
        .then(response => {  
      console.log(response.data);
    });

How would return the response.data?

mental shadowBOT
  • Consider reading #how-to-get-help to improve your question!
  • Explain what exactly your issue is.
  • Post the full error stack trace, not just the top part!
  • Show your code!
  • Issue solved? Press the button!
  • Marked as resolved by OP
shadow veldt

weatherData will be a promise but by literally doing return response.data

low drift
shadow veldt

Show the code and log weatherData

low drift

And im running into the ReferenceError: response is not defined error

Response code

                await interaction.reply({content: response.data, ephemeral: showChoice});
const weatherData = axios.get(`API`)
        .then(response => {  
      console.log(response.data);
      return response.data
    });
shadow veldt
  1. weatherData is a promise, I told you this already. So you need to await after =
  2. weatherData holds the value of response.data, so use that
shadow veldt

There’s only one that makes logical sense in JavaScript

low drift

I see it

Thank youi

I apologize

Im very new to JS

tryna get a feel for it

shadow veldt

No worries

low drift

Thank you!