Skip to content

Net

Type module

Sources

Items from Net can be imported/included and used via following ways.

/**
* Import via main package
* Access items like: am5.net.myVariable
*/
import * as am5 from "@amcharts/amcharts5";
/**
* Import via: Net.ts
* Access items like: $net.myVariable
*/
import * as $net from "@amcharts/amcharts5/Net";

Variables

Net does not have any variables.

Functions

load(url: string,
target?: A,
options?: INetRequestOptions
)

Returns Promise

Loads a file from url and returns a Promise of the result. The promise is rejected, with error: true in the result, if the request fails or its status is not 200.

// Using await
let response = await am5.net.load( "http://www.my.com/data.json" );
console.log( response.response );

// Using then()
am5.net.load( "http://www.my.com/data.json" ).then( ( response ) => {
  console.log( response.response );
} );
// Using then()
am5.net.load( "http://www.my.com/data.json" ).then( function( response ) {
  console.log( response.response );
} );

More info: Getting the most out of net.load utility

readBlob(blob: Blob)

Returns Promise

Returns textual representation of a Blob object.