Open Gerhut opened 8 years ago
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...
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
Just to make sure I really understand you correctly:
simple = true
304
responsetransform
that shall be able to change the statusCode
to 200
request-promise
does not return the response to .catch(...)
anymorerequest-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?
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:
- You do a request with option simple = true
- The server sends a 304 response
- You apply the transform that shall be able to change the statusCode to 200
- request-promise does not return the response to .catch(...) anymore
- 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 https://github.com/request/promise-core/issues/2#issuecomment-249938821, or mute the thread https://github.com/notifications/unsubscribe-auth/ACYml2U8EOgGVU_f3YeSTBP1m6cHAd0lks5quVP1gaJpZM4KCnAF .
Used in transform 304 response to 200 response with local cache.