Hey Eric! I had a small question.
Hannan Ali
1

Because promises are eager, not lazy, calling axios.get() will immediately fire off a network request, which is a state change that is visible outside the function. Therefore, a function that fires off a network request is not pure.

There is something similar to a promise that you could return instead: a task. A function that returns a task can be pure because tasks are lazy, not eager. The network request won’t be triggered until after the task is returned and the function is finished running.

Alternatively, you could make getIdentity() pure by returning a function that returns the promise:

const getIdentity = name => () => {
return axios.get('https://getyourinfo.pk/' + name);
};

// Then call it:
const fetch = getIdentity('foo'); // this function is pure
fetch() // this function is not pure
.then(identity => console.log(identity))
.catch(handleErrors)
;
One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.