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

Is it possible to skip/disable normalization of a request body? #2323

Closed
1 task done
vetlevo opened this issue Jan 26, 2024 · 1 comment
Closed
1 task done

Is it possible to skip/disable normalization of a request body? #2323

vetlevo opened this issue Jan 26, 2024 · 1 comment

Comments

@vetlevo
Copy link

vetlevo commented Jan 26, 2024

What would you like to discuss?

I have a use case where I need to send a request to an API that expects a POST request with:
'content-type': 'application/x-www-form-urlencoded'

and form data that looks like URLSearchParams...:
attr1=abcdef&date=ge2021-01-02T07:51:01Z&date=le2021-01-04T08:00:00Z

Got performs a normalization step on the body and correctly transforms it to:

{
    "attr1": "abcdef",
    "date": [
        "ge2023-12-31T23:00:00.000Z",
        "le2024-01-07T23:00:00.000Z"
    ]
}

Of course I would like to have the maintainers of the API make it compliant with the format that is most commonly used, but it is unlikely to happen any time soon.

Hence, I was hoping to use the 'beforeRequest' hook to pass the body on the format they expect, but it seems the 'normalization' happens after.

I would like to keep using got for this, and not have to use another request library for this particular use case. Is this possible with got?

Checklist

  • I have read the documentation.
@vetlevo
Copy link
Author

vetlevo commented Jan 26, 2024

It seems to even be the default behvaiour of fetch as well, so I guess not... I will probably have to do it with something a bit lower level, like node:http sadly ... That's what happens when you have to use APIs that are not following the most widely accepted use of standards ...

@vetlevo vetlevo closed this as completed Jan 26, 2024
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

No branches or pull requests

1 participant