Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow transform non-2xx request to 2xx request in simple mode. #2

Open
Gerhut opened this issue Sep 21, 2016 · 4 comments
Open

Allow transform non-2xx request to 2xx request in simple mode. #2

Gerhut opened this issue Sep 21, 2016 · 4 comments

Comments

@Gerhut
Copy link

Gerhut commented Sep 21, 2016

Used in transform 304 response to 200 response with local cache.

@analog-nico
Copy link
Member

That is a very good idea!

This would mean the transform function would just change the statusCode and the response would be "reresolved" accordingly.

function (body, response, resolveWithFullResponse) {
    // Get data from the cache etc.
    response.statusCode = 200
    return response
}

However, this solution doesn't go with resolveWithFullResponse = false yet...

@Gerhut
Copy link
Author

Gerhut commented Sep 22, 2016

If resolveWithFullResponse = false set, it usually means the status code (also headers etc) are not important to the coder. So I think just retain the status code when resolveWithFullResponse = false is OK

@analog-nico
Copy link
Member

Just to make sure I really understand you correctly:

  1. You do a request with option simple = true
  2. The server sends a 304 response
  3. You apply the transform that shall be able to change the statusCode to 200
  4. request-promise does not return the response to .catch(...) anymore
  5. Instead, request-promise returns the response to .then(...)

Correct? Or are you working with simple = false to begin with and are not worried about getting the response returned to .catch(...) anyway?

@Gerhut
Copy link
Author

Gerhut commented Sep 28, 2016

Yep this is my opinion.

I tried to working with simple = false, but I also need others rejections
like 404.

Transform non-304 into rejection under simple = false makes my code even
more complicated...

Sincerely
George Chung

2016-09-28 1:35 GMT+08:00 Nicolai Kamenzky notifications@github.com:

Just to make sure I really understand you correctly:

  1. You do a request with option simple = true
  2. The server sends a 304 response
  3. You apply the transform that shall be able to change the statusCode
    to 200
  4. request-promise does not return the response to .catch(...) anymore
  5. Instead, request-promise returns the response to .then(...)

Correct? Or are you working with simple = false to begin with and are not
worried about getting the response returned to .catch(...) anyway?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#2 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACYml2U8EOgGVU_f3YeSTBP1m6cHAd0lks5quVP1gaJpZM4KCnAF
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants