Skip to content

Commit a6ba63c

Browse files
committed
[PW-11.6/ret] Exclude use "substr()" method
Correct server logic/file, replace "substr()" with "slice()" method. Deserv(s) attention: - that the "substr()" method is now deprecated (according to MDN). core: B-3 / JS-BL
1 parent 1b0e04e commit a6ba63c

File tree

1 file changed

+2
-2
lines changed
  • core-courses/3-js-basic-level/11-server-async-await/11-6-pw-11-server-async-await/students-db-server

1 file changed

+2
-2
lines changed

core-courses/3-js-basic-level/11-server-async-await/11-6-pw-11-server-async-await/students-db-server/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ module.exports = createServer(async (req, res) => {
207207
}
208208

209209
// убираем из запроса префикс URI, разбиваем его на путь и параметры
210-
const [uri, query] = req.url.substr(URI_PREFIX.length).split("?");
210+
const [uri, query] = req.url.slice(URI_PREFIX.length).split("?");
211211
const queryParams = {};
212212

213213
// параметры могут отсутствовать вообще или иметь вид a=b&b=c
@@ -235,7 +235,7 @@ module.exports = createServer(async (req, res) => {
235235
} else {
236236
// /api/students/{id}
237237
// параметр {id} из URI запроса
238-
const itemId = uri.substr(1);
238+
const itemId = uri.slice(1);
239239
if (req.method === "GET") return getStudent(itemId);
240240
if (req.method === "PATCH")
241241
return updateStudent(itemId, await drainJson(req));

0 commit comments

Comments
 (0)