0
測試koa.js並在客戶端獲取。我正試圖在服務器上發佈一些數據。我正在使用下面的代碼未定義。我不確定爲什麼。Koa路由器沒有看到帖子正文?
我已經檢查this
,this.request
,this.req
,等我不能從客戶端查找REQ我的數據?
服務器
import koaRouter from 'koa-router'
// Post route
router.post('/api/upload', function *(next) {
console.log('UPLOAD WORKS', this.req.body)
this.status = 200
})
app
.use(bodyParser())
.use(router.routes())
.use(router.allowedMethods())
控制檯給我不確定。
客戶
fetch('/api/upload', {
method: 'post',
body: 'Hello'
}).then(function(response) {
console.log(response)
}).catch(function(err) {
// Error :(
});
可以複製的[這](http://stackoverflow.com/questions/31504814/koa-router-and-post) –
我跨過來了。我仍然錯過了我的數據。我想它可能是因爲fetch()。 –
如果你發現了一些關於你的問題的文章,請在文中加入這些文章,並告訴你爲什麼不是你的問題的答案。 –