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

serializeRequest performs JSON.stringify on a Buffer #277

Open
szmarczak opened this issue Sep 26, 2022 · 1 comment
Open

serializeRequest performs JSON.stringify on a Buffer #277

szmarczak opened this issue Sep 26, 2022 · 1 comment
Labels
bug Something isn't working. t-tooling Issues with this label are in the ownership of the tooling team.

Comments

@szmarczak
Copy link

szmarczak commented Sep 26, 2022

function serializeRequest(config: ApifyRequestConfig): ApifyRequestConfig {

if (type === 'application/json' && typeof config.data === 'object') {
config.data = stringifyWithFunctions(config.data);

function stringifyWithFunctions(obj: JsonObject) {
return JSON.stringify(obj, (_key, value) => {
return typeof value === 'function' ? value.toString() : value;
});
}

I was wondering why I was receiving {"type":"Buffer","data":[...]} instead of actual data...
This breaks .call(buffer, { contentType: 'application/json' }).

@szmarczak szmarczak added the bug Something isn't working. label Sep 26, 2022
@szmarczak
Copy link
Author

Passing a string does not work either because axios does this:

https://github.com/axios/axios/blob/892c241773e7dda78a969ac1faa9b365e24f6cc8/lib/defaults/index.js#L119

@mtrunkat mtrunkat added the t-tooling Issues with this label are in the ownership of the tooling team. label Mar 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working. t-tooling Issues with this label are in the ownership of the tooling team.
Projects
None yet
Development

No branches or pull requests

2 participants