Using this package with Fetch API requires no additional setup, and it can be used as described in API.
Make sure an instance of Potion is created and use that to register resources:
import {Potion} from 'potion-client/fetch';
const potion = new Potion({prefix: '/api'});Now the API endpoints can be registered either using the @potion.registerAs() class decorator:
import {Item} from 'potion-client/fetch';
// An instance of Potion is available either globally or imported from somewhere in your app
@potion.registerAs('/foo', {
readonly: ['name']
})
class Foo extends Item {
name: string;
}Or by using the potion.register() method:
import {Item, readonly} from 'potion-client/fetch';
class Foo extends Item {
@readonly
name: string;
}
potion.register('/foo', Foo);