Datasource Http

Edit on GitHub

This document explains the Datasource Http service in the Components Library.


Datasource Http is an Angular Service that fetches data from URLs via HTTP as configured in the Datasource configuration. Datasource Http supports caching strategy (see Cache) that can be configured via config and used before the request is made, when applicable.

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).
        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 {}


Below you can find interfaces for the Datasource Http:

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

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