Datasource Http
Edit on GitHub
You are browsing a previous version of the document. The latest version is 202212.0.
This document explains the Datasource Http service in the Components Library.
Overview
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).
<spy-select
[datasource]="{
type: 'http',
url: '/html-request',
method: 'POST',
}"
>
</spy-select>
Service registration
Register the service:
declare module '@spryker/datasource' {
interface DatasourceRegistry {
http: DatasourceHttpService;
}
}
@NgModule({
imports: [
DatasourceModule.withDatasources({
http: DatasourceHttpService,
}),
],
})
export class RootModule {}
Interfaces
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',
}
Thank you!
For submitting the form