Function remoteData

  • Native fetch but with built-in AbortController

    example with composition (maybe you want to implement your own version that also wraps up authorization headers):

    import { tracked } from '@glimmer/tracking';
    import { use, resource } from 'ember-resources';
    import { remoteData } from 'reactiveweb/remote-data';

    class Demo {
    @tracked id = 1;

    @use myData = resource((hooks) =>
    remoteData(hooks, `https://...${this.id}`)
    );
    }

    The same example, but without @use

    import { tracked } from '@glimmer/tracking';
    import { resource } from 'ember-resources';
    import { remoteData } from 'reactiveweb/remote-data';

    class Demo {
    @tracked id = 1;

    myData = resource(this, (hooks) =>
    remoteData(hooks, `https://...${this.id}`)
    );
    }

    Type Parameters

    • T = unknown

    Parameters

    • __namedParameters: ResourceAPI
    • url: string
    • options: undefined | RequestInit = {}

    Returns State<T>

Generated using TypeDoc