question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[fetch-driver-interceptor: onSuccess] should we return Response or body?

See original GitHub issue

I am trying to use interceptor, but I have discovered that returning Response object in onSuccess doesn’t seem to be useful as I can’t .json my response as Response can only read once. Do you think we should return the Response body to onSuccess instead?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
klis87commented, Jul 15, 2018

@leesiongchan Since new relese of Fetch driver, you could read response.data instead of response.json() - https://github.com/klis87/redux-saga-requests/releases/tag/redux-saga-requests-fetch%400.7.0

Writing in case you still need it.

1reaction
klis87commented, Mar 14, 2018

Can u give an example? As maybe this is really not to be placed inside interceptor? Interceptors should be used only really for global stuff. What you can do for example is to create new saga:

import { success } from 'redux-saga-requests';

function* waitForASuccess() {
  while (true) {
    const action = yield take(success('SOME_REQUEST'));
    // check action.data and dispatch some action here
  }
}

function* rootSaga() {
  yield createRequestInstance(fetch, { driver: fetchDriver });
  yield all([
    watchRequests(),
    fork(waitForASuccess),
  ]);
}

In the same way you can add dozens of other sagas, waiting for success, error, abort, request actions of any type/types. Will it solve your use case?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Should a RESTful 'PUT' operation return something....
@systemPAUSE Nice answer. One small point: if you are not going to be returning a response body to a successful operation, I would...
Read more >
RESTful API. Should I be returning the object that was created ...
8 Answers 8 · It is OK (and most likely desirable) to return something in a POST/PUT response body. · How this is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found