Skip to content

Commit b58fb82

Browse files
committed
removed compulsion of implementation of both plugin method
1 parent ef5b0bd commit b58fb82

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/core/lib/request.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ function fetchRetry(stack, queryParams, fetchOptions, resolve, reject, retryDela
9898
var plugins = stack.plugins;
9999
if (plugins && plugins != undefined)
100100
plugins.forEach(pluginObj => {
101-
pluginObj.onRequest(stack, {url, option})
101+
if (typeof pluginObj.onRequest == 'function') pluginObj.onRequest(stack, {url, option})
102102
});
103103

104104
fetch(url, option)
@@ -111,7 +111,8 @@ function fetchRetry(stack, queryParams, fetchOptions, resolve, reject, retryDela
111111
if (response.ok && response.status === 200) {
112112
data.then(json => {
113113
for (let index = 0; index < plugins.length; index++) {
114-
json = plugins[index].onResponse(stack, {url, option}, response, json)
114+
if (typeof plugins[index].onResponse == 'function')
115+
json = plugins[index].onResponse(stack, {url, option}, response, json)
115116
}
116117
resolve(json);
117118
})

0 commit comments

Comments
 (0)