Reputation: 183
I try koajs today and write the helloworld example:
/**
* index.js
*/
var koa = require('koa');
var app = koa();
app.use(function*(){
this.body = 'hello world';
console.log('success!');
});
app.listen(8080);
then I run the index.js file and visit the localhost:8080 in browser, but the console.log seems triggered twice everytime I refresh the page. why ?
Upvotes: 0
Views: 360
Reputation: 1006
Look at your network tab in your browser console or log the requests on the server, it's a request for the favicon.
You can log your server request like this
app.use(function*(){
this.body = 'hello world';
console.log(this.url);
});
You will see in your console :
/
/favicon.ico
Upvotes: 5