Datasource Http

Edit on GitHub

Datasource Http is an Angular service in the components library that fetches data from URLs via HTTP as configured in the Datasource configuration. Datasource Http supports the caching strategy that can be configured via config and used before the request is made.


Check out an example usage of the Datasource Http.

Service configuration:

type A datasource type.
url A datasource request URL.
method A datasource request method; GET by default.

Usage example:

        type: 'http',
        url: '/html-request',
        method: 'POST',

Service registration

Register the service:

declare module '@spryker/datasource' {
    interface DatasourceRegistry {
        http: DatasourceHttpService;

    imports: [
            http: DatasourceHttpService,
export class RootModule {}


Datasource Http interfaces:

export interface DatasourceHttpConfig extends DatasourceConfig {
    url: string;
    method?: string;
    dataIn?: DatasourceHttpConfigDataIn;
    cache?: CacheStrategyConfig;

export enum DatasourceHttpConfigDataIn {
    Params = 'params',
    Body = 'body',