0

I just started using the library "node-fetch". In the documentation there a serveral examples on how to use the library:

fetch('https://api.github.com/users/github')
    .then(function(res) {
        return res.json();
    }).then(function(json) {
        console.log(json);
    });

All the examples are written in this style of concatenated then-calls.

Couldn't I just have one single then-call and be done with it?

Like this?

fetch('https://api.github.com/users/github')
    .then(function(res) {
        console.log(res.json());
    });

Whats the advantage of having multiple then-calls?

Tobias Gassmann
  • 10,411
  • 12
  • 54
  • 82

0 Answers0