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

JSON middleware does not work on Deno Deploy #156

Closed
fucksophie opened this issue Feb 20, 2022 · 1 comment · Fixed by #157
Closed

JSON middleware does not work on Deno Deploy #156

fucksophie opened this issue Feb 20, 2022 · 1 comment · Fixed by #157

Comments

@fucksophie
Copy link
Contributor

Issue

Setup:

  • Deno Version: 1.17.1 (release, x86_64-pc-windows-msvc)
  • v8 Version: 9.7.106.15
  • Typescript Version: 4.5.2
  • Opine Version: 2.1.1

Details

Error:

BadRequestError: Bad Request
    at decodeContent (https://deno.land/x/opine@2.1.1/src/middleware/bodyParser/read.ts:66:15)
    at read (https://deno.land/x/opine@2.1.1/src/middleware/bodyParser/read.ts:18:21)
    at jsonParser (https://deno.land/x/opine@2.1.1/src/middleware/bodyParser/json.ts:106:15)
    at Layer1.handle [as handle_request] (https://deno.land/x/opine@2.1.1/src/router/layer.ts:49:15)
    at next (https://deno.land/x/opine@2.1.1/src/router/route.ts:76:19)
    at Route.dispatch (https://deno.land/x/opine@2.1.1/src/router/route.ts:56:5)
    at Layer1.handle [as handle_request] (https://deno.land/x/opine@2.1.1/src/router/layer.ts:49:15)
    at https://deno.land/x/opine@2.1.1/src/router/index.ts:196:30
    at Function.process_params (https://deno.land/x/opine@2.1.1/src/router/index.ts:236:16)
    at next (https://deno.land/x/opine@2.1.1/src/router/index.ts:191:14)

Error occurs when sending a payload to a endpoint.

Code:

import { opine, json } from "https://deno.land/x/opine@2.1.1/mod.ts";

const app = opine();

app.post("/api/v1/test", json(),(req, res) => {
	res.send(req.body);
})

app.listen(8081, () => {
	console.log("testing")
});
@fucksophie fucksophie changed the title JSON middleware does not work on Deploy JSON middleware does not work on Deno Deploy Feb 20, 2022
cmorten pushed a commit that referenced this issue Feb 20, 2022
* update deps to include readAll
* move away from Deno.readAll to streams/conversion
@cmorten
Copy link
Owner

cmorten commented Feb 20, 2022

Thanks for the fix @yourfriendoss - released in https://deno.land/x/opine@2.1.2

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

Successfully merging a pull request may close this issue.

2 participants