From e5487c106ab7ed2e82fa61b6a83eee7da5c9ed90 Mon Sep 17 00:00:00 2001 From: David Frank Date: Wed, 28 Jan 2015 17:46:15 +0800 Subject: [PATCH] Update README.md simplify co example --- README.md | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 078303c..d73958b 100644 --- a/README.md +++ b/README.md @@ -115,11 +115,8 @@ fetch('http://httpbin.org/post', { method: 'POST', body: form, headers: form.get var co = require('co'); co(function *() { - var res = yield fetch('https://api.github.com/users/github') - .then(function(res) { - return res.json(); - }); - + var res = yield fetch('https://api.github.com/users/github'); + var json = yield res.json(); console.log(res); }); ``` @@ -146,7 +143,7 @@ default values are shown, note that only `method`, `headers` and `body` are allo method: 'GET' , headers: {} // request header, format {a:1} or {b:[1,2,3]} , follow: 20 // maximum redirect count, 0 to disable - , timeout: 0 // request timeout in ms, 0 to disable, note that it's for each request when following redirect + , timeout: 0 // request timeout in ms, 0 to disable, note that redirect restart timeout , compress: true // support gzip/deflate content encoding, false to disable , size: 0 // maximum response body size in bytes, 0 to disable , body: empty // request body, can be a string or readable stream