Skip to content

POST with same property name in path as well as in body gets removed #21

Open
@mattdemichele-pearson

Description

@mattdemichele-pearson

As an example, say you have a POST endpoint defined as:

POST /api/notes/id/{id}
that expects a body that looks like:

{
  id: 1,
  text: 'xyz'
}

Because the path and the body have a property with the same name, it ends up breaking. In this example, "id" gets put in the path, but then gets removed from the body payload that gets sent in the request.

I narrowed this down to being a problem in getFetchParams(), where the getPath() function ends up deleting keys from the payload. The way the code is written, I see why this is a necessity. I am wondering if there are any suggestions?

One thought I had was to add a third optional parameter to the function that create() returns that can be an array of strings for "keys to persist into body payload"

delete payload[key]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions