Skip to main content

Request

Helpers

getDataFromUrl

Returns the response data of a given url as a buffer object.

import { getDataFromUrl, schematic } from '@hug/ngx-schematics-utilities';
import { Rule } from '@angular-devkit/schematics';

export default (options: any): Rule =>
schematic('my-schematic', [
(): Rule => {
const url = 'https://my-data-source-url';
const data = await getDataFromUrl(url);
...
}
]);

getJsonFromUrl

Returns the response data of a given url as a JSON object.

import { getJsonFromUrl, schematic } from '@hug/ngx-schematics-utilities';
import { Rule } from '@angular-devkit/schematics';

export default (options: any): Rule =>
schematic('my-schematic', [
(); Rule => {
const url = 'https://cdn.jsdelivr.net/npm/@angular/core@latest/package.json';
const packageJson = await getJsonFromUrl(url);
...
}
]);