I use the ajax to get information in Vue.js, so my code is:
fetch('http://work1999.kcg.gov.tw/open1999/ServiceRequestsQuery.asmx/ServiceRequestsQuery').then(function (response) {
if (response.ok) {
return response.json();
} else {
commit(roottypes.LOADING, false);
}
});
But I use Airbnb JavaScript Style, so I get error: https://imgur.com/a/ePeUG
In order to solve no-else-return and prefer-arrow-callback, so I change my code to:
fetch('http://work1999.kcg.gov.tw/open1999/ServiceRequestsQuery.asmx/ServiceRequestsQuery').then((response) => {
if (response.ok) {
return response.json();
}
commit(roottypes.LOADING, false);
});
And then, I got a new error: https://imgur.com/2qZOqD5
But only when response is ok, it will return, others will do the function. How Could I solve this problem? Thanks.