johnwick0831
johnwick0831

Reputation: 948

Better way of calling 'call' redux-saga

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.

Upvotes: 0

Views: 133

Answers (1)

Yury Tarabanko
Yury Tarabanko

Reputation: 45121

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

Upvotes: 2

Related Questions