Accepted answer

The issue is that the d3.json function ( with one parameter returns the request. You would then have to issue that request.

The 'typical' use is to have a second parameter, with a callback function. This is an asynchronous callback, so you can't assign the return value to a var.

Here is what I suggest:

var url = '/courses/1';
d3.json( url, function( error, data ) {
    console.log( data );
    // do all actions required now that the data is retrieved
} );

Related Query