Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Node.JS Error You have tried to call .the(), .catch() [closed]

dt65231

Coder
You have tried to call .the(), .catch()

**Question.**
1. What is the reason for the problem?
2. How to fix the problem?

I have a project, I want to launch it.
The project is located in the folder `e:\Test\Pro01\`.
**I've done it:**
- I opened the Windows console;
- I entered the command `cd e:\Test\Pro01\`;
- I entered the `node app.js`;
- result: I get an error message;

**I use:**
- Windows-10 x64;
- VSCode;
- Visual Studio 2022 Community(NodeJS installed);
- Node.js (c:\Program Files\nodejs\node.exe);
- Wampserver64;
- MySql;


----------


Attach
------

**Error message:**
*e:\Test\Pro01>node app.js
Start at http://localhost:3000
You have tried to call .then(), .catch(), or invoked await on the result of query that is not a promise,
which is a programming error.
Try calling con.promise().query(), or require('mysql2/promise') instead of 'mysql2'
for a promise-compatible version of the query interface. T
o learn how to use async/await
or Promises check out documentation
at https://www.npmjs.com/package/mysql2#using-promise-wrapper,
or the mysql2 documentation at https://github.com/sidorares/node-mysql2/tree/master/documentation/Promise-Wrapper.md
e:\Test\Pro01\node_modules\mysql2\lib\commands\query.js:41
throw new Error(err);
^
Error: You have tried to call .then(), .catch(), or invoked await on the result of query that is not a promise, which is a programming error. Try calling con.promise().query(), or require('mysql2/promise') instead of 'mysql2' for a promise-compatible version of the query interface. To learn how to use async/await or Promises check out documentation at https://www.npmjs.com/package/mysql2#using-promise-wrapper, or the mysql2 documentation at https://github.com/sidorares/node-mysql2/tree/master/documentation/Promise-Wrapper.md
at Query.then (e:\Test\Pro01\node_modules\mysql2\lib\commands\query.js:41:11)
at MySQLStore.query (e:\Test\Pro01\node_modules\express-mysql-session\index.js:392:12)
at MySQLStore.<anonymous> (e:\Test\Pro01\node_modules\express-mysql-session\index.js:110:9)
at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:68:3)
Node.js v18.7.0
e:\Test\Pro01>*

27.07.2022_21-28-56.png


27.07.2022_19-29-24.png



27.07.2022_19-14-02.png

27.07.2022_19-12-39.png
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom