fetch.d.ts 779 B

123456789101112131415161718192021222324252627282930313233
  1. import has = require('./has');
  2. import types = require('./types');
  3. declare namespace fetch {
  4. interface IResult {
  5. ok: boolean;
  6. status: number;
  7. statusText: string;
  8. url: string;
  9. clone(): IResult;
  10. text(): Promise<string>;
  11. json(): Promise<any>;
  12. xml(): Promise<Document | null>;
  13. blob(): Promise<Blob>;
  14. headers: {
  15. keys(): string[];
  16. entries(): Array<string[]>;
  17. get(name: string): string;
  18. has(name: string): boolean;
  19. };
  20. }
  21. }
  22. declare function fetch(
  23. url: string,
  24. options?: {
  25. method?: string;
  26. timeout?: number;
  27. headers?: types.PlainObj<string>;
  28. body?: any;
  29. }
  30. ): Promise<fetch.IResult>;
  31. export = fetch;