-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
TypeError: Failed to execute 'fetch' in Blazor Webassembly #2248
Comments
Yes, GET requests cannot have a body. Why are you setting the content type header if your request has no content??? |
Even without a header it gives an error. I created this repository for testing. |
I am wondering if you read the docs https://restsharp.dev/docs/usage/client#blazor-support |
Yes, |
Sorry, but I don't really understand you. Your repository has this code on the page: var options = new RestClientOptions("https://apibihml.value4u.com.br");
var client = new RestClient(options); The documentation clearly says that you need to register the client using the Blazor version of builder.Services.AddSingleton(new RestClient(new HttpClient())); followed by a page example where you use the injected client. The docs additionally points out that:
I don't see any of this in your repository. |
In addition, calling the API in Postman doesn't really help. Blazor HttpClient uses the fetch function, and the best way to understand what's going on is to open the dev tools in the browser and look at both console and network calls tabs. You'll see if the request actually has a body, what the server returns (if anything), or if the fetch hasn't been executed, as well as the error message from the fetch call. |
I hadn't updated github because it gave the same error. But I updated the repository and the same error continues. |
I am using the code below
Erro in blazor
▶ | ErrorMessage | 'TypeError: Failed to execute 'fetch' on 'Window': Request with GET/HEAD method cannot have body.' |
The text was updated successfully, but these errors were encountered: