[API] onResponse was not obeying return dataType #3653
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I'm new to Semantic and trying to get brain around a few concepts. Thank you for this awesome work.
I am exploring using Semantic with a legacy backend. The legacy backend returns JSON that requires processing. One key in the returned JSON is 'html' from which, say a tab's HTML contents, would be pulled.
Though my question applies to all API calls, running with tabs is a useful case study. A tab is hardwired to seek and get returned from server plain HTML. My objective would be to leverage as much Semantic tab logic as possible but get it to work with this legacy JSON backend.
This discussion regarding a related topic discusses the use of 'mockResponseAsync' for a related purpose:
#1736
It seems onResponse is the simpler solution. I was glad to find it. But I did not understand why the response text was being transformed into a hash before being sent to the 'onResponse' callback. The first thing I need to do on the other end is reassemble the original response text so I can process it in proprietary fashion. Maybe there's a reason for this transformation?
My suggestion retains the default and offers a flag to skip this wasteful transformation so it needn't happen every server hit if it is not necessary.
Maybe I misunderstood 'mockResponseAsync' and that's where I should be working? If not, maybe the default behavior for 'onResponse' transforming the text might be confusing to others as well.
Thanks for the awesome work. I look forward to getting deeper. Even without this change, it's cool that hooks are in place so I can wire Semantic into a legacy app.