Closed sujesharukil closed 9 years ago
I believe jQuery's processData
option exists to support content like form data, but Aurelia's client tries to handle that automatically. If we don't serialize objects, the XHR will .toString()
them and send [object Object]
.
Can you provide some info about what type you're passing as content, and what you'd like the result to be? It may be that we can improve the handling of other types of content, but if not I think adding an option to skip transformation should be straight forward.
I am trying to upload a file directly to azure. The way I have done it previously is to chunk the data as uint8array and post that. As such, jquery's processData: false prevents the data from getting paramed via jquery.param. Tried the same thing with Aurelia and the data got stringified (which is the default) in content processor. A flag in the request helper will do the trick. I can put a pull request for this.
Ah, that makes sense. A PR would be great!
I'd also like to have this feature (and be able to configure it globally for all requests, so i don't have to do it every time i send the request).
My use-case is to add smth like request interceptor/transformers that would inspect given object properties and transform the value based on property type (detected by propertyValue instanceof SomeClass
).
Currently i can't do it with neither request interceptor or transformer, because:
1) in request interceptor (and also in helper added by addHelper) message content is string, so JSON.parse(message.content)
would return an object with properties that don't pass instanceof SomeClass
test, as after serialization and deserialization all objects loose type information about constructor function that was used to construct them before serialization (constructor function is used by instanceof
check which i use for detecting how to convert the value).
2) transformer doesn't work, because message is not set by the time transformer is called.
Is there a way to achieve it with existing features?
jQuery's ajax has processData: false to prevent stringifying content. Aurelia's contentTransformer has no way of preventing JSON.stringify if content should not be stringified. Provide a way to not call contentTransformer if a flag is set to false.