Reporting an uncaught (in promise) error. The solution
There are two Solutions:
1. when using Axios to request an interface, add catch() behind then():
-
export function stopMCUMixTranscode(params) { return new Promise((resolve, reject) => { axios .post(********, params) .then((res) => { resolve(res) }) .catch((err) => { reject(err) }) }) }
2. Use return promise Reject (new error (res.msg | ‘error’)) to catch and handle exceptions. It needs to be use .catch(err=>{console.log(err)}) to catch exceptions when the request comes back,
return Promise.reject(error).catch(err=>{console.log(err)}) // Return the error message returned by the interface
Read More:
- How to solve Uncaught (in promise) error in VUE?
- Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to crrent location: “/home“
- [Solved] Uncaught (in promise) Error: Avoided redundant navigation to current location:
- Vue Error: Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to current location
- [Solved] Uncaught (in promise) TypeError: XXX.a is not a constructor
- [Solved] Uncaught (in promise) DOMException: Failed to load because no supported source was found.
- request.js?b775:101 Uncaught (in promise) Error: Failed to convert value of type ‘java.lang.String’ to required type ‘java.lang.Long’;
- [Solved] Echarts Error: Uncaught (in promise) Error: Initialize failed: invalid dom.
- [Solved] Turf.js error: uncaught (in promise) error: the solution of invalid unit
- ArcGIS API for JavaScript Error Uncaught(in promise): TypeError: xxx is not a constructor
- [Solved] echarts Draw Errror: echarts-d9fd185e.js:31447 Uncaught (in promise) Error: Initialize failed: invalid dom.
- JS native implementation Promise.all
- VueUncaught (in promise) NavigationDuplicated: Avoided redundant navigation to current location: “/
- [Solved] vue-roter 4 Error: Error: Invalid route component/Uncaught (in promise) Error: Invalid route component
- Method to solve uncaught typeerror: cannot set property ‘onclick’ of null error
- How to Solve JS error: Unexpected end of JSON input,Unexpected token u in JSON at position 0
- [Solved] Vue Error: Error in v-on handler (Promise/async): “[object object]“
- [Vue warn]: Error in callback for watcher “value“ (How to Solve)
- How to Solve pinia Error in ts File
- [Solved] Uncaught ReferenceError: axios is not defined