cmorten/superdeno

Submitting a payload with a get request results in request termination error

viztastic opened this issue · 5 comments

image

Issue

Submitting a payload with a get request results in request termination error

Setup:

  • Deno Version: 1.1.3
  • v8 Version: 8.5.216
  • Typescript Version: 3.9.2
  • SuperDeno Version: 1.5.1

Please replace this line with a short description of the issue.

Details

        await superdeno("http://localhost:8080/api")
        .get("/endpoint/")
        .send({
            "name": "asset X",
            "thingType": "truck-asset-type"
        })
       .expect(200);

results in the error above. It seems like superdeno doesn't support sending payloads with a get request?

Submitting a payload with a GET request is appropriate in this case as there'll be no side effect to the API. The body is essentially a DSL to help filter the response.

Given the 2014 updates with RFCs 7230-7237 SuperDeno really should really support bodies on GET (with the caveat that some legacy servers will reject).

Thanks for raising this - will try and take a look this weekend!

SuperDeno is in effect a wrapper around SugerAgent using fetch to make the requests. One thing that would useful to the investigation (if you have the time!) would be to see the result of a manually constructed fetch to your API endpoint with the same setup as SuperDeno is meant to be providing you so we can see the result / error message (the current one isn’t very insightful!)

Actually, before that:

await superdeno("http://localhost:8080/api")
        .get("/api/endpoint/")

You appear to have duplicated /api, is that intentional? I would expect that you should be doing:

await superdeno("http://localhost:8080")
        .get("/api/endpoint/")

Would you mind trying that out? (Unless this is deliberate on your part!)

Hey sorry i mindlessly put that there without realising how it came across. I actually renamed the real API endpoints for clarity more than anything but created confusion in the process. Fixed it in the original post ^

fetch worked perfectly, below is a screenshot incase you want a sense of how I implemented it:

image

also just so you know testWithFreshDb({ name: ... is just a wrapper around Deno.test with a database setup/tear-down. Shouldn't get in the way of superdeno but happy to share if you'd like to be sure.

PS: I've switched my implementation to just use query params for now (turns out Angular doesn't support get payloads either). Sharing this so you're not feeling any pressure to fast track this. Although I do think it'll be nice to include for completeness at some stage.

Should hopefully have been fixed in #12 and released in 1.6.1 -> https://github.com/asos-craigmorten/superdeno/releases/tag/1.6.1