WebMar 14, 2024 · Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'data') 这个错误消息表明在执行代码时发生了一个错误,该错误导致无法读取未定义的属性。. 这通常是因为您尝试访问了一个未定义的变量或对象的属性。. 为了解决这个错误,您需要找出导致错误的 ... Web1 day ago · It returns undefined because all of the database stuff hasn't been done yet. It is still fetching the data, etc. You need to wait for the function to finish. It's called promise and the promise either resolves or rejects. So we need to wait for the promise to fulfill. methods.getPunishmentData().then(data => { console.log(data) })
Promise.prototype.then() - JavaScript MDN - Mozilla Developer
WebMar 30, 2024 · The behavior of the returned promise (call it p) depends on the handler's execution result, following a specific set of rules. If the handler function: returns a value: p … WebAug 1, 2024 · When the promise is created, its state is set to “pending” and its result is “undefined.” If the request is successful, axios will call its built-in solve() callback to set the promise’s ... schedule football uva
Resolving the JavaScript Promise Error "TypeError: Cannot Read
WebAug 14, 2024 · The promise object returned by the new Promise constructor has these internal properties: state — initially "pending", then changes to either "fulfilled" when resolve is called or "rejected" when reject is called. result — initially undefined, then changes to value when resolve (value) is called or error when reject (error) is called. WebAug 2, 2024 · You get a promise of a result. This means you will get undefined as the return value of apiGetAll. So const api will always equal undefined. If you still want to use promises, that’s fine. But async/await would have made it clearer that you have to set state in the the callback because the value doesn’t exist until the promise returns. Blockquote WebMay 22, 2024 · After all, you get this error when calling the then () method on a Promise. And the TypeError indicates you are calling then () on undefined, which is a hint that the … schedule football premier league