Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

what is wrong here ? #407

Closed
ghost opened this issue Feb 4, 2015 · 5 comments
Closed

what is wrong here ? #407

ghost opened this issue Feb 4, 2015 · 5 comments

Comments

@ghost
Copy link

ghost commented Feb 4, 2015

Hello,

I try to solve this exercise from kick-off-koa :


Create an app that checks the Content-Type of the request. If it's application/json, return {message: 'hi!'} with appropriate con
tent headers. Otherwise, return ok as a string.

so I have this :


var koa = require('koa')

var app = koa(); 

app.use( function *() { 
     if (this.request.is('application/json ')) {  
        this.body = {message: 'hi' };
        } else { 
            this.body = 'ok';
        }
}); 

app.listen(process.argv[2]); 

but if I try to run in with kick-off-koa run file.js I see this error :


 Error connecting to submission server(http://localhost:40158/), options: {"method":"POST","data":{"foo":"bar"},"headers":{"conte
nt-type":"application/json; charset=utf-8","Content-Length":7,"User-Agent":"node-urllib/0.5.18 node/v0.11.16 (linux 3.13.0-29-gen
eric; x64)"},"timeout":5000,"maxRedirects":10}. Error: connect ECONNREFUSED
    at exports._errnoException (util.js:746:11)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:983:19)

So it seems there is something wrong with my app.

Can anyone give me a tip where I can find the culprit ?

Roelof

@dougwilson
Copy link
Contributor

Hi! Make sure you have at least v1.1.0 of kick off koa installed.

@ghost
Copy link
Author

ghost commented Feb 4, 2015

Thanks,

I have this version [email protected] installed so that is not the problem

@dougwilson
Copy link
Contributor

Gotcha :) There have been some race conditions where your server doesn't end up on the expected port. I'll wait for someone else to come by here to help :)

@ghost
Copy link
Author

ghost commented Feb 4, 2015

oke, then the only thing I can do is wait :(

@dead-horse
Copy link
Member

migrate to koajs/kick-off-koa#27

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants