3.1 KiB
3.1 KiB
id, title, challengeType, forumTopicId, localeTitle
id | title | challengeType | forumTopicId | localeTitle |
---|---|---|---|---|
587d7fb2367417b2b2512bf5 | Get Route Parameter Input from the Client | 2 | 301513 | Получить ввод параметров маршрута от клиента |
Description
req.params
.
route_path: '/user/:userId/book/:bookId'Построить эхо-сервер, смонтированный по маршруту
actual_request_URL: '/user/546/book/6754'
req.params: {userId: '546', bookId: '6754'}
GET /:word/echo
. Ответьте с помощью объекта JSON, взяв структуру {echo: word}
. Вы можете найти слово для повторения в req.params.word
. Вы можете проверить свой маршрут из адресной строки вашего браузера, посетив несколько подходящих маршрутов, например, your-app-rootpath / freecodecamp / echo
Instructions
GET /:word/echo
. Respond with a JSON object, taking the structure {echo: word}
. You can find the word to be repeated at req.params.word
. You can test your route from your browser's address bar, visiting some matching routes, e.g. your-app-rootpath/freecodecamp/echo
.
Tests
tests:
- text: 'Test 1 : Your echo server should repeat words correctly'
testString: 'getUserInput => $.get(getUserInput(''url'') + ''/eChOtEsT/echo'').then(data => { assert.equal(data.echo, ''eChOtEsT'', ''Test 1: the echo server is not working as expected'') }, xhr => { throw new Error(xhr.responseText); })'
- text: 'Test 2 : Your echo server should repeat words correctly'
testString: 'getUserInput => $.get(getUserInput(''url'') + ''/ech0-t3st/echo'').then(data => { assert.equal(data.echo, ''ech0-t3st'', ''Test 2: the echo server is not working as expected'') }, xhr => { throw new Error(xhr.responseText); })'