2.1 KiB
2.1 KiB
id | title | challengeType |
---|---|---|
587d7fb2367417b2b2512bf5 | Get Route Parameter Input from the Client | 2 |
Description
req.params
object.
route_path: '/user/:userId/book/:bookId'Build an echo server, mounted at the route
actual_request_URL: '/user/546/book/6754'
req.params: {userId: '546', bookId: '6754'}
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
Instructions
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); })'
Challenge Seed
Solution
// solution required