-
-
Notifications
You must be signed in to change notification settings - Fork 754
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Pass FormData using feathers-rest-client #1744
Comments
It's probably because the rest-client will always request restClient.service('test').create(fData, {
headers: {
'Content-Type': 'multipart/form-data'
}
}); |
I tested it earlier on, but it doesn't seem to work. By setting the
When using native const fData = new FormData();
fData.append('filename', 'x');
fData.append('file', attachments);
// This will generate the Boundary
await fetch(url/service, {
method; 'POST',
body: fData,
})
// This will not
restClient.service('test').create(fData, {
headers: {
'Content-Type': 'multipart/form-data'
}
}); Even when using fetch, I tried to print out the {
filename: 'x',
file: '[object File]'
} multer doesn't seem to be able to decode the body and grab the files to process. I have tried with both When I print I will be working on trying to get a repo this couple of days so maybe you could get a better idea on where went wrong. Meanwhile, if you could think of anything for me to try out, just let me know. |
Ah, I think this may be a bug for the REST client always using |
That seem to be the same in I actually have tried with |
Hi @daffl, I have worked out a repo @ feathers-rest-upload-issue Some keys points:
So I had to cast to any for now.
Hope this helps! |
Sorry to bother, but what did you do at the end? I am having the exact same issues. :'C |
Am using native fetch for now. But you can configure
This will work as well |
So.... is this going to be actioned? Personally, I would really quite like to use the client (for multipart and with fetch) as I don't want to lose my abstraction just because there is a bug. |
Hey, does somebody know if there was any solution to this issue in the meantime? I appear to have the same issues with the rest client (configured with fetch) as the OP. |
Hi,
I would like to use
feathers-rest-client
and send data through rest with attachments (FormData), together with the rest of the body. The application is setup and configure with bothrest
andsocket
client. If there are data with attachments, it will userest
client to communicate with server, otherwise, usesocket
client.I have configured
feathers-rest-client
to pass data to server.feathers-rest-client
is configured something like this.There's a form for user to fill up some fields, and add some attachment. After which I hope to call the
test
endpoint usingfeathers-rest-client
as such..Server has something like this.
However, no matter how I change it, I am not able to get and extract the data at the server side. Meaning to say, I think the data is set wrongly, and hence, multer does not know how to extract/decode from the correct
field
to get theattachments
and so on.But If I were to use
POSTMAN
to send a request to my endpoint, server is able to extract/decode the data correctly. Meaning to say, the file are passed throughmulter
to extract the attachments (available infeathers.params.files
), and the body are able to retrieve fromcontext.data
.Any idea what am I doing wrong?
Thanks.
The text was updated successfully, but these errors were encountered: