Giter Club home page Giter Club logo

Comments (6)

appellation avatar appellation commented on June 12, 2024

Discord does not send a body of [object EventEmitter]. Can you come up with less complex repro steps so we can eliminate all of these frameworks?

from discord-api-docs.

Artrix9095 avatar Artrix9095 commented on June 12, 2024

Ive tested this out without hono just using raw nextjs api functions and still got the same result, going to test it out with the default bun server next

from discord-api-docs.

Artrix9095 avatar Artrix9095 commented on June 12, 2024
Bun.serve({
    fetch(req) {
        console.log('content-type', req.headers.get('content-type'))
        console.log('body', req.body)
        console.log('method', req.method)
        return Response.json({
            test: 1
        })
    },
    port: 3000
})

Still gives the same response:
image

For some reason discord is giving back a ReadableStream thats literally just [object EventEmitter] when turned into text. Instead of actual json like its supposed to.
Theres a possibility this could be a ngrok problem but I doubt it.

from discord-api-docs.

appellation avatar appellation commented on June 12, 2024

Can you please provide the actual text of the body? A ReadableStream is expected.

from discord-api-docs.

Fyko avatar Fyko commented on June 12, 2024

This is the expected behavior, since Bun uses the Web specification of Request. So Request#body is of type ReadableStream.

If you want the JSON body of the request, you must use Request#json.

Bun.serve({
    async fetch(req) {
        console.log('content-type', req.headers.get('content-type'))
-       console.log('body', req.body)
+       console.log('body', await req.json())
        console.log('method', req.method)
        return Response.json({
            test: 1
        })
    },
    port: 3000
})

from discord-api-docs.

Artrix9095 avatar Artrix9095 commented on June 12, 2024

This fixes it, so i'm assuming this isn't a problem with discord, probably hono/nextjs. Thanks. (ill post edit this post with a solution if anyone else encounters this)

EDIT: for some reason running nextjs with bun via bun --bun dev totally breaks nextjs api routes. Removing the --bun seems to fix it. Probably need to post an issue on nextjs at some point

from discord-api-docs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.