使用 queue.js 将 HTTP header 添加到 d3.json

Adding HTTP header to d3.json with queue.js

我知道我可以通过执行以下操作将 header 添加到 D3 JSON 请求:

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

但是在使用 queue 的 defer 时如何添加这个 header?

queue()
  .defer(d3.json, "http://localhost:8080/data")
在您调用 get 之前,

d3.json 不会实际执行请求。所以,如果你的目标是发出一个延迟的 http 请求,你可以这样做:

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