0
我可能不明白關於JS的一些東西,但我有一個問題,寫出對頁面主體的最純粹的響應。喜歡這裏:KOA中最純粹的請求
var koa = require('koa')
, session = require('koa-session')
, mount = require('koa-mount')
, koaqs = require('koa-qs')
, accesslog = require('koa-accesslog')
, router = require('koa-router')()
, app = koa();
var Grant = require('grant-koa')
, grant = new Grant(require('./config.json'))
app.keys = ['grant']
app.use(accesslog())
.use(session(app))
.use(mount(grant))
.use(router.routes())
.use(router.allowedMethods());
koaqs(app)
router.get('/handle_facebook_callback', function *(next) {
getProfile(this.query.access_token);
\t
})
var config = {
"facebook": {
"https://graph.facebook.com": {
"__domain": {
"auth": {
"auth": {"bearer": "[0]"}
}
},
"{endpoint}": {
"__path": {
"alias": "__default"
}
}
}
}
}
var request = require('request')
, purest = require('purest')({request})
, facebook = purest({provider: 'facebook', config})
function getProfile(access_token, responseToBody){
\t facebook.get('me')
.auth(access_token)
\t \t \t .request(function (err, res, body) {
\t \t \t \t this.body=JSON.stringify(body,null,2);
})
}
if (!module.parent) app.listen(3000);
console.log('oh!GG is running on http://localhost:3000/');
我會承擔facebook.request功能 「this.body = JSON.stringify(身體,空,2);」部分應該將回應寫入正文中,但不會。 問題到底是什麼?
Ude body.innerHtml –
你能澄清一下,如果它在服務器上或用戶端? –
KOA是nodejs =] – Medardas