Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] koa 相关库的介绍文档不够详细,如何使用 #165

Open
dong-lufei opened this issue Jun 4, 2023 · 1 comment
Open
Labels
enhancement New feature or request

Comments

@dong-lufei
Copy link

// 查询所有用户
router.get("/users", async (ctx, next) => {
  const sql = "SELECT * FROM users"
  connection.query(sql, (err, results, fields) => {
    if (err) {
      console.error(err)
      ctx.body = { success: false, message: "查询失败" }
      return
    }
    console.log("get", results)
    ctx.body = { success: true, data: results }
  })
})

我根路由都访问成功,这个路由咋404,但是数据库写进去了而且读成功,console 那行成功有正确数据

@dong-lufei dong-lufei added the enhancement New feature or request label Jun 4, 2023
@dong-lufei
Copy link
Author

哦,知道原因了,好像是 mysql 造成的。我把 npm i mysql 改用 npm i mysql2 就成功了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant