#Switched to Hono to use with Bun

1 messages · Page 1 of 1 (latest)

shadow pelican
#

it worked with Express before

shadow pelican
#
  static async loginUser(req, res) {
        const body = req.body;
        console.log('body', body)

Hey, this is from Express, but I'm trying to switch to Hono
request json not working

         const {error} = loginValidation(body);
                      ^
TypeError: res.status is not a function. (In 'res.status(400)', 'res.status' is undefined)
        const body = await req.body.json();

also not working

static async loginUser(context) {
        const body = await context.req.json();
        console.log('body', body)
        const {error} = loginValidation(body);
        console.log('error', error)
        if (error) {
            return context.status(400).send(error.details[0].message);
        }
#

my Postman Headers

shadow pelican
#

ok so fixed the json bug

#

hopefully

#

as I get

body {
  username: "testuser",
  password: "ShoPass1997S"
}
hash $2b$10$n3Z17ftN1ApMswaNUazJdO0Q0RlSsUwhh7ac2Cq4T0p3a4Y7erc6G
#

in console log

#

new bug is this

28 | const hash = await Bun.password.hash(body.password);
29 | const isPasswordValid = await Bun.password.verify(user.password, hash);
30 |
31 | if (!isPasswordValid) {
32 | return context.status(401).send('Password is incorrect');
^