-
-
Notifications
You must be signed in to change notification settings - Fork 793
Description
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 both rest and socket client. If there are data with attachments, it will use rest client to communicate with server, otherwise, use socket client.
I have configured feathers-rest-client to pass data to server.
feathers-rest-client is configured something like this.
const app = feathers();
const restClient = rest('http://localhost:3030')
app.configure(restClient.fetch(window.fetch));
There's a form for user to fill up some fields, and add some attachment. After which I hope to call the test endpoint using feathers-rest-client as such..
fData = {
field1: 'test',
field2: 'test2',
file: [attachments] // this is a FormData
}
// Also tried
FormData fData = new FormData();
fData('field1', 'test');
fData('field2', 'test2');
fData('file', attachments);
restClient.service('test').create(fData);
Server has something like this.
app.use('/test', multer.array('file'), setReqFileToFeatherFile(), createService());
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 the attachments 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 through multer to extract the attachments (available in feathers.params.files), and the body are able to retrieve from context.data.
Any idea what am I doing wrong?
Thanks.
