Reputation: 9024
const _post = params => {
instance
.post(params.url, params.data)
.then(response => {
params.onSuccess(response);
})
.catch(error => {
params.onFailure(error);
});
};
So I have this helper code written by someone else in the team. What I am looking for is when ever some tries to call this function, It should tell them that what properties it is expecting. Such as it is expecting three keys url, data, onSuccess, onFailure
How can we achieve that. I tried looking JS Doc specs but it only let us tell that the param is object like @param {Object} param
Upvotes: 2
Views: 66
Reputation: 1200
Try
/**
* some func.
* @param {Object} params - an object.
* @param {string} params.url - a url.
* @param {Object} params.data - an object.
* @param {Function} params.onSuccess .
* @param {Function} params.onFailure .
*/
function _post(params){}
Upvotes: 3