d3.request("/path/to/resource")
.header("X-Requested-With", "XMLHttpRequest")
.header("Content-Type", "application/x-www-form-urlencoded")
.post("a=2&b=3", callback);
But based on the d3-fetch readme, it's unclear if it's possible to post data. Given that the d3-request readme says to use d3-fetch instead, it'd be good to either have "translated" versions of examples that send data or point to other code/libraries with that functionality.
I was working on a project with @newick and @maiwann using the GIthub API and we used the delete repo endpoint. This endpoint returns an HTTP 204 result on success with an empty body.
When calling d3.json
, this results in a failing promise with an error indicating a JSON.parse
error. This is probably due to trying to parse an empty string (which is not valid JSON)
We did not expect this outcome with a 204 (which is supposed to indicate success)
We solved our problem by using d3.text
instead (which does not perform a parsing, so no error), but wondered whether it might make sense to change the behavior of d3.json
, hence this issue