Reputation: 65
Can someone explain, how I make a POST method using Feathers and test it in postman. I notice that there are two parameters, "data" and "params". What are their differences? Can someone give me a complete example how to create POST method in feathers and test it in postman?
Thanks
Upvotes: 1
Views: 1853
Reputation: 51
The data is the actual data passed to the service method, ex: a form data. and the params contains the provider (i.e REST, Socket.io or Primus), connection details, authenticated user details and other info related to that service.
For post method you can use the create(data, params) method of the service that you are calling and do your post activity there like creating records like below.
app.use('/messages', {
messages: [],
create(data, params) {
this.messages.push(data);
// Your post activity here
return Promise.resolve(data);
}
});
And in postman use can use the URL http://localhost:3030/messages and in the request body provide the JSON you want to pass as a data to the POST method
ref: https://docs.feathersjs.com/api/services.html
Upvotes: 2