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

254
Views
TypeError: Cannot read properties of undefined (reading 'dataResponse') at callback

I am trying to query an api according to the instructions you gave me, but I am getting this error:

(index):30 Uncaught TypeError: Cannot read properties of undefined (reading 'dataResponse') at callback ((index):30) at HTMLButtonElement.onclick ((index):23) callback @ (index):30 onclick @ (index):23

api instructions https://drive.google.com/file/d/1KHLduw46l1e3aIGCliTvn1gYuJhv8Npy/view?usp=sharing could you help me please

<!doctype html>
<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

      <!-- Bootstrap CSS -->

    <title>Duke Business School</title>
    <script
    data-user="user(user@test.com) "
    data-password="(password 'sha256Hex')"
    data-button=false
    data-response=true
    data-amount="100.01"
    data-commerce="Affinitas"
    src="http://52.22.36.22:9020/js/transactions.js">
   </script> 
  </head>
  <body>

        <button onclick="callback();"> pagar</button>
      </div>
    </section>

   <script>
    function callback(data){
    alert("RESPUESTA OBTENIDA EN HTML");
    alert("Operación: " + data.dataResponse.description + " Autorización: " +
   data.dataResponse.authorization)
    }
   </script>
  </body>
</html>

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

0

It looks like your error here is a simple user error, and has nothing to do with the API.

You're using the button onclick to call "callback()" without any passed parameters. This is the same as: "callback(undefined);"

I believe your logic is a little messy here. Your button should call the API, and the API should call the callback. Instead, you're calling the callback with the button, skipping the API altogether.

Typically, the error TypeError: Cannot read properties of undefined refers to trying to reference a property within a property within an object or object's property that doesn't exist.

The problem is, you're trying to read the property "description" of dataResponse, but dataResponse doesn't exist. But the compiler doesn't know what dataResponse is because the variable data doesn't exist.

data.dataResponse.description // <- Same as: Undefined.undefined.undefined

about 4 years ago · Juan Pablo Isaza Report

0

Root cause is here onclick="callback();", you are not passing any data in callback and trying to access data in your function which is actually undefined.

I am not sure about this api but on your button click

  1. you should redirecting user to the gateway page which will have both the scripts independent of your button

or

  1. you should append the mentioned script in dom on button click and it will automatically take care of callback
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!