-
Type:
Bug
-
Status: Closed
-
Resolution: Fixed
-
Affects Version/s: 7.3.10.1 DXP SP1, 7.3.X, 7.4.13 DXP GA1, Master
-
Fix Version/s: 7.4.3.8 CE GA8, 7.4.13 DXP U4, Master
-
Component/s: JS APIs and Utilities
-
Labels:
-
Fix Priority:2
-
Sprint:S04E30 - Sea Change
-
Git Pull Request:
The javascript method Liferay.Service for calling remote services has four arguments. With the last argument you can pass an error callback which should be triggered whenever the status code of the ajax request is >= 400. This actually never happens. The success callback is always used.
Steps to reproduce:
- Choose an arbitrary liferay remote service (e.g. GroupServiceImpl)
- Trigger a method via javascript that causes an exception, for example:
Liferay.Service( '/group/get-group', { groupId: 123 }, function(response) { console.log('success') }, function(error) { console.log('error') }, );
Expected behaviour:
The error callback should be invoked since no group with groupId 123 exists and the status code of the response is 404.
Actual behaviour:
The success callback is invoked.
It's pretty obvious that the incorrect code can be found here: modules\apps\frontend-js\frontend-js-web\src\main\resources\META-INF\resources\liferay\liferay.js. In the success callback of the method Liferay.Util.fetch there is a missing check for response.ok which you should normally do when using the fetch api.
- causes
-
LPS-150923 Liferay.Service invokes Error Callback in case of empty response object
- Closed