w3up
w3up copied to clipboard
Client.agent() : expression uncallable
Upon trying to do an easy task of letting the user use a delegation and access the space to upload, i tried following the docs. However there seem to be an issue with the examples provided in the docs.
import * as Delegation from '@ucanto/core/delegation';
import * as Client from '@web3-storage/w3up-client';
const client = await Client.create();
const apiUrl = `/api/w3up-delegation/${client.agent().did()}`;
console.log('apiurl', apiUrl);
const response = await fetch(apiUrl);
const data = await response.arrayBuffer();
const delegation = await Delegation.extract(new Uint8Array(data));
if (!delegation.ok) {
throw new Error('Failed to extract delegation', { cause: delegation.error });
}
const space = await client.addSpace(delegation.ok);
client.setCurrentSpace(space.did());
const cid = await client.uploadFile(file);
i get this error as a result : This expression is not callable because it is a 'get' accessor. Did you mean to use it without '()'?
Type 'Agent<Service>' has no call signatures.ts.
and of course even despite removing the () following agent, the delegation extraction just fails. I still have no idea how i can work around this to make the users upload directly to my space using my generated delegation..