-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
StateOption data as promise or pass through when mocks are not available #168
Comments
hey @k3nsei,
Leonardo.addState({
name: 'Get Comments',
verb: 'GET',
url: 'api/comments',
options: [{
"name": "Success with function",
"status": 200,
"data": (request) => {
// calculate response in real time
return Leonardo.goToServer;
}]
} @tsachis @MrFrankel any other ideas? |
With the above solution, it will be hard to define many different states for a single url and control them from the UI\API, which is what Leonardo is all about. I suggest we add a new example:
@dwido WDYT? |
I think that @tsachis approach is quite good. |
@tsachis seems that this approach is problematic when working with Sinon, the reason is that the decision if to mock a state or let it pass through is done when the xhr.open method is being called when there are no parameters of the request |
@tsachis this can be closed |
Currently
data
property inStateOption
can be only (primitive | Object | Function). But I have url that is responsible for returning many variants of data based on request payload (kinda like GraphQL). So I need to have ability to serve mock when some conditions are metting my predicates in other case it need to pass through request to real backend and return data from there.So to do that I need to be able to set
data
property asPromise
or have some pass through option to call real backend to get data.The text was updated successfully, but these errors were encountered: