Skip to content

Use named types for API request params #5477

@sosnovsky

Description

@sosnovsky
          How about we declear types like below so that we can make code easy to read and simple and avoid code duplication?
type JsonRequestParams = {
  method: 'POST' | 'PUT';
  data: Dict<Serializable>;
};

type TextRequestParams = {
  method: 'POST';
  data: string;
  contentType: string;
};

type GetRequestParams = {
  method: 'GET';
  data?: UrlParams;
};

type DeleteRequestParams = {
  method: 'DELETE';
};

params?: JsonRequestParams | TextRequestParams | GetRequestParams | DeleteRequestParams

Originally posted by @ioanmo226 in #5372 (comment)

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions