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
Calling response.json() when processing an error request (40x) returns a promise, not the data in the body #170
Comments
@bggolding It is specified in the
I would expect A working example would be:
|
can this be closed? |
On 26 Jan 2019, at 03:55, Jimmy Wärting ***@***.***> wrote:
can this be closed?
I guess. Because I didn’t get a response to this issue and also that isomorphic fetch doesn’t support relative url’s I moved to doing my queries with jQuery which, frankly, feels like I’m stepping back in time.
Ben.
|
Well did you read my response then? Because it clearly points to the documents showing that your original issue is the correct behavoir according to the specs in that |
On 28 Jan 2019, at 20:20, trixn86 ***@***.***> wrote:
I guess. Because I didn’t get a response to this issue [...].
Well did you read my response then? Because it clearly points to the documents showing that your original issue is the correct behavoir according to the specs in that .json() returns a promise. Did you try the code in my answer? Did it work for you?
Yes, I read your response and tried it but I still couldn’t get it to work: on an error return, trying to resolve the promise just always returned a promise; I could never get the error message.
My customer was pushing hard for me to deliver the project I was working on and this issue (coupled with the module's refusal to work with relative url’s) meant I had to stop debugging and change to something that I thought was inferior but worked.
Ben.
|
I agree with @trixn86's diagnosis … |
When I send an error from my restful api back to the server, I want to include a message. Flask has nice support for this and I can say:
I can see the data in the body of the response and content-type is application/json.
In my app I’m using isomorphic-fetch and I’m saying:
Trouble is,
data
always comes out being an unresolved promise. If I poke around inside using the debugger I can see my data (it’s in[[PromiseValue]]
) but I can’t get it. I've tried calling.then()
on it to try to resolve it but that just seems to generate another Promise.How is this supposed to work? This code works fine when the response isn't an error.
The text was updated successfully, but these errors were encountered: