I want to know how i can expand function and add more arguments for it like object. For example I have function
function xml(){}
xml.prototype.get = function(url, config /*optional*/){
//something with restApi
}
and i want to use mock data for every method and i try to add mock and mockData like new parameters in object but if i don't pass config argument all brokes, but i want to use it outside object.
const httpClient = Object.create(xml)
httpClient.get = function(url, config /*optional*/,{mock,mockData}={}){
if(mock){
return new Promise(resolve=>resolve({data: mockData}))
}
return this.get(url, config)
}