Passing parameters to a callback function using arrow function
You can do that:
const fetchItems = (callback, ...params) => {
//Do whatever you want with the params
callback(response);
}
Example of usage:
const fetchItems = (callback, ...params) => {
callback(params);
}
fetchItems (console.log, 'foo', 1);
More of less you can do it the same way
const getCountries = (data, callback) => {
//After ajax success
callback(response);
}
getCountries("data", ()=>{});