Creating the Metadata controller instance
import MetadataController from "issue-metadata";
const controller = new MetadataController('my_metadata_ID', {
owner: 'my_name',
repo: 'my_repo',
headers: {
authorization: `Bearer my_GITHUB_API_TOKEN`,
},
});
await controller.setMetadata(1, 'foo', 'bar');
// In body of issue #1:
// <!-- my_metadata_ID = {"foo":"bar"} -->
await controller.setMetadata(1, { foo: 'bar' });
// In body of issue #1:
// <!-- my_metadata_ID = {"foo":"bar"} -->
await controller.setMetadata(1, 'complex', [{ bar: 'baz' }]);
// In body of issue #1:
// <!-- my_metadata_ID = {"foo":[{"bar":"baz"}]} -->
Get metadata stored on issue
let metadata = await controller.getMetadata(1, 'foo');
// metadata === "bar"
metadata = await controller.getMetadata(1);
// metadata === {foo: "bar"}
metadata = await controller.getMetadata(1, 'complex');
// metadata === [{ bar: 'baz' }]