avadev/AvaTax-REST-V2-JS-SDK

TypeError: Failed to execute 'fetch' on 'Window': Request with GET/HEAD method cannot have body.

adrianchia opened this issue ยท 4 comments

Hi,

When I tried the taxRatesByAddress API on Angular 4, it shows: the following error

TypeError: Failed to execute 'fetch' on 'Window': Request with GET/HEAD method cannot have body.

The same method works fine from Node.JS backend application. It turns out that HEAD or GET requests should not have a body, see JakeChampion/fetch#402, changing from null to undefined resolves the issue.

https://github.com/avadev/AvaTax-REST-V2-JS-SDK/blob/master/lib/AvaTaxClient.js#L2788

Hi @adrianchia
The problem is that you are making a HTTP GET request, by its definition GET requests don't take request body, instead, GET requests only hits an endpoint with certain parameters embedded in the request url. You may find the format of the request url(query string) here

Let me know if you have additional question,
Han

image

Hi @han8909227
I ran into a similar issue for resolveAddress(). Maybe this.restCall() should be called with payload undefined instead of null?
https://github.com/avadev/AvaTax-REST-V2-JS-SDK/blob/master/lib/AvaTaxClient.js#L380

Thanks!

Get([FromQuery]ObjectInput input)
โ€œ[FromQuery]โ€

This helped in my API using Golang and Mux.

Hi @adrianchia
The problem is that you are making a HTTP GET request, by its definition GET requests don't take request body, instead, GET requests only hits an endpoint with certain parameters embedded in the request url. You may find the format of the request url(query string) here

Let me know if you have additional question,
Han

image

This helped in my project with golang using Mux and node-fetch.