Adding HTTP header in d3.json with queue.js

I know that I can add a header to a D3 JSON request by doing the following:

d3.json("http://localhost:8080/data")
  .header("Application-ID", "1")

But how do I add this header when using a deferred queue?

queue()
  .defer(d3.json, "http://localhost:8080/data")
+4
source share
1 answer

d3.jsondoesn't actually fulfill the request until you call get. So, if your goal is to make a pending http request, you can simply do:

var req = d3.json("http://localhost:8080/data")
    .header("Application-ID", "1");
queue().defer(req.get);
+6
source

Source: https://habr.com/ru/post/1623164/


All Articles