Tell us what’s happening:
I got 1 last error from the 4th Project in Back End Development & APIs. It is:
You can add from, to and limit parameters to a GET /api/users/:_id/logs request to retrieve part of the log of any user. from and to are dates in yyyy-mm-dd format. limit is an integer of how many logs to send back.
I’m sure that the ‘from’ ‘to’ and ‘limit’ is working, but the test still failing. Could there be anything wrong with it?
Already resolved. It’s because the limit query parameter doesn’t work quiet well. Here is the comparison between the old & new program behind limit functionality:
NEW:
for (let i = 0; i < arrLog.length; i++) {
logDate = Date.parse(arrLog[i]['date'])
if (logDate >= logFrom && logDate <= logTo) {
arrLogFilter.push(arrLog[i]);
}
if (logLim && logLim == (arrLogFilter.length)) {
break;
}
}
OLD:
for (let i = 0; i < arrLog.length; i++) {
logDate = Date.parse(arrLog[i]['date'])
if (logDate >= logFrom && logDate <= logTo) {
arrLogFilter.push(arrLog[i]);
}
if (logLim && logLim == i + 1) {
break;
}
}