@spree/storefront-api-v2-sdk
Version:
Node module to easily integrate your JavaScript or TypeScript application with Spree API V2. You can create an entirely custom Storefront in JS/TS with this package including one page checkout, Single Page Apps, PWAs and so on
27 lines (26 loc) • 1.32 kB
TypeScript
import { SpreeError, SpreeSDKError } from './errors';
import FetchError from './errors/FetchError';
import type { Fetcher } from './interfaces/ClientConfig';
import type { ErrorType } from './interfaces/errors/ErrorType';
import type { HttpMethod, ResponseParsing } from './interfaces/FetchConfig';
import type { JsonApiResponse } from './interfaces/JsonApi';
import type { ResultResponse } from './interfaces/ResultResponse';
import type { IToken } from './interfaces/Token';
export declare type EndpointOptions = {
fetcher: Fetcher;
};
export default class Http {
fetcher: Fetcher;
constructor({ fetcher }: EndpointOptions);
protected spreeResponse<ResponseType = JsonApiResponse>(method: HttpMethod, url: string, tokens?: IToken, params?: any, responseParsing?: ResponseParsing): Promise<ResultResponse<ResponseType>>;
/**
* The HTTP error code returned by Spree is not indicative of its response shape.
* This function determines the information provided by Spree and uses everything available.
*/
protected classifySpreeError(error: FetchError): ErrorType;
protected processError(error: Error): SpreeSDKError;
protected processSpreeError(error: FetchError): SpreeError;
protected spreeOrderHeaders(tokens: IToken): {
[headerName: string]: string;
};
}