0

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 ?

jabez128
  • 183
  • 2
  • 15

1 Answers1

5

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
Maxdow
  • 1,006
  • 11
  • 21
  • you are right, you can't view the favicon request in the developper console. But two solution : in chrome you can watch all events throught chrome://net-internals/#events ( and then filter with your URL ) or , best is to log server requests – Maxdow May 08 '14 at 20:51