I am using ngx-uploader and with the data section inside the uploadInput, I pass additional data:
startUpload(): void {
const event: UploadInput = {
type: 'uploadAll',
url: this.uploadUrl,
method: 'post',
data: this.data,
headers: { 'Authorization': 'Token ' + this.userToken }
};
this.uploadInput.emit(event);
}
The problem is that the data I am passing looks like this
this.data = {
myData: {
isThereData: true
}
}
When reading the res.body
inside my express, my data is returned as [object Object].
router.post('/path', upload.any(), (req, res, next) => {
console.log(req.body) // logs [object, Object]
})
I can stringify the data before sending it to express, but then I need to pass the data content type along with the data from ngx-uploader
, which I am unsure how to do, or if it is even possible.
I know I cannot pass an object because of the UploadInput
:
export interface UploadInput {
...
data?: {
[key: string]: string | Blob;
};
...
}
Is there another way to go about this?
from ngx-uploader - Passing JSON data Object to uploadInput data, returning [object Object]
No comments:
Post a Comment