user1596371
user1596371

Reputation:

Adding HTTP header to d3.json with queue.js

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")

Upvotes: 4

Views: 1011

Answers (1)

Jamie
Jamie

Reputation: 2301

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);

Upvotes: 6

Related Questions