jabez128
jabez128

Reputation: 183

why trigger console twice when i use koajs

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

Answers (1)

Maxdow
Maxdow

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

Related Questions