我正在使用fetch方法在服务器上进行API调用,并注意到它同时发出多个请求,因此它在服务器上增加了30%RPM
有人可以帮助防止多次通话并了解其原因吗?
您可以在下面看到React Native代码和服务器日志
反应原生代码
fetch(url, {
method: "GET",
headers: {
'Accept': "application/json",
'Content-Type': "application/json"
}
}).then((resp) => {
if (resp.status === 200) {
resp.text().then(function(data) {
var resData = JSON.parse(data);
}
}
}
服务器日志
[Wed Jan 25 12:14:08.323939 2017] [:error] [pid 13832] 2017-01-25 12:14:08.323658 URL: /driver/upcoming-bookings/ User: {'id': '', 'email': 'Anonymous'} HTTP Method: GET Params: {u'imei': u'359375062977098'}
[Wed Jan 25 12:14:08.631057 2017] [:error] [pid 14306] 2017-01-25 12:14:08.630777 URL: /driver/upcoming-bookings/ User: {'id': '', 'email': 'Anonymous'} HTTP Method: GET Params: {u'imei': u'359375062977098'}
[Wed Jan 25 12:14:09.103341 2017] [:error] [pid 14307] 2017-01-25 12:14:09.102915 URL: /driver/upcoming-bookings/ User: {'id': '', 'email': 'Anonymous'} HTTP Method: GET Params: {u'imei': u'359375062977098'}