2.0 KiB
2.0 KiB
id, title, localeTitle, challengeType
id | title | localeTitle | challengeType |
---|---|---|---|
587d7fb2367417b2b2512bf5 | Get Route Parameter Input from the Client | 从客户端获取路由参数输入 | 2 |
Description
req.params
对象中找到。
route_path: '/user/:userId/book/:bookId'
actual_request_URL: '/user/546/book/6754'
req.params: {userId: '546', bookId: '6754'}
Instructions
GET /:word/echo
的回显服务器。使用结构{echo: word}
响应JSON对象。您可以在req.params.word
找到要重复的req.params.word
。您可以从浏览器的地址栏测试您的路线,访问一些匹配的路线,例如 your-app-rootpath/freecodecamp/echo
Tests
tests:
- text: '测试1:您的echo服务器应该正确重复单词'
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: '测试2:您的echo服务器应该正确重复单词'
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