Better way of calling 'call' redux-saga

133 views Asked by At

Using the example from react-boiler-plate:

const response = yield call(() => axios.get(requestURL));

Is there a better way to call axios.get, what if i have axios.post? How can I clean this up a bit without having to do '() =>' just to force it into a function.

Thanks for any advice.

1

There are 1 answers

3
Yury Tarabanko On BEST ANSWER

If you want to unit test using simple deep equals assertions you could do

const response = yield call([axios, 'get'], requestUrl)

const response = yield call([axios, axios.get], requestUrl)

This allows you to avoid creation of anonymous lambda on every call.

Docs