Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

329
Views
Axios "TypeError: Cannot read properties of undefined (reading 'then')" on request

I'm trying making a GET request using Axios to my Discord bot, but i'm getting a problem.

var axios = require("axios");
var response;

function getItemPrice(name, time) {
  axios.get("https://url.com/api/id=${name}&time=${time}")
}

response = getItemPrice("name", "time");

response.then(function(dataResponse){
  console.log(dataResponse.data);
}
).catch(function(error){
  if(error){
    console.log(error);
  }
});

I changed the URL. Show this in console ↓

TypeError: Cannot read properties of undefined (reading 'then')

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You have to use backticks (``) in URL to use template literals. And also use return from function getItemPrice.

Example:

axios.get(`https://url.com/api/id=${name}&time=${time}`)
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!