Adding HTTP header to d3.json with queue.js

1k Views Asked by At

I'm aware 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 queue's defer?

queue()
  .defer(d3.json, "http://localhost:8080/data")
1

There are 1 best solutions below

0
Jamie On BEST ANSWER

d3.json doesn't actually perform the request until you call get. So, if your goal is to make a deferred http request, you can just do:

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