| description | Retrieve the result of a completed task with iExec’s getResultFromCompletedTask method. Easily access task outcomes by providing the task ID. |
|---|
Method to get the result of a completed task.
import { IExecDataProtectorCore, getWeb3Provider } from '@iexec/dataprotector';
const web3Provider = getWeb3Provider('PRIVATE_KEY');
const dataProtectorCore = new IExecDataProtectorCore(web3Provider);
// ---cut---
const completedTaskResult = await dataProtectorCore.getResultFromCompletedTask({
taskId: '0x7ac398...',
});import { type GetResultFromCompletedTaskParams } from '@iexec/dataprotector';Type: Address
Address of the task ID data you'd like to get the result from.
import { IExecDataProtectorCore, getWeb3Provider } from '@iexec/dataprotector';
const web3Provider = getWeb3Provider('PRIVATE_KEY');
const dataProtectorCore = new IExecDataProtectorCore(web3Provider);
// ---cut---
const completedTaskResult = await dataProtectorCore.getResultFromCompletedTask({
taskId: '0x7ac398...', // [!code focus]
});Type: string
Under the hood, a protected data is a zip file. With this path parameter, you
can specify the file you're interested in. The zip file will be uncompressed for
you, and only the desired file will be given as the result.
import { IExecDataProtectorCore, getWeb3Provider } from '@iexec/dataprotector';
const web3Provider = getWeb3Provider('PRIVATE_KEY');
const dataProtectorCore = new IExecDataProtectorCore(web3Provider);
// ---cut---
const completedTaskResult = await dataProtectorCore.getResultFromCompletedTask({
taskId: '0x7ac398...',
path: 'content', // [!code focus]
});Type: string
If you have previously saved or generated a RSA keypair, you can reuse it in further calls.
It needs to be the private key corresponding to the public key initially used to encrypt the protected data.
import { IExecDataProtectorCore, getWeb3Provider } from '@iexec/dataprotector';
const web3Provider = getWeb3Provider('PRIVATE_KEY');
const dataProtectorCore = new IExecDataProtectorCore(web3Provider);
// ---cut---
const completedTaskResult = await dataProtectorCore.getResultFromCompletedTask({
taskId: '0x7ac398...',
pemPrivateKey: '-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----', // [!code focus]
});Type: OnStatusUpdateFn<ConsumeProtectedDataStatuses>
Callback function to be notified at intermediate steps.
import {
IExecDataProtectorCore,
getWeb3Provider,
} from '@iexec/dataprotector';
const web3Provider = getWeb3Provider('PRIVATE_KEY');
const dataProtectorCore = new IExecDataProtectorCore(web3Provider);
// ---cut---
const completedTaskResult =
await dataProtectorCore.getResultFromCompletedTask({
taskId: '0x7ac398...',
onStatusUpdate: ({ title, isDone }) => { // [!code focus]
console.log(title, isDone); // [!code focus]
}, // [!code focus]
});You can expect this callback function to be called with the following titles:
'CONSUME_RESULT_DOWNLOAD';
'CONSUME_RESULT_DECRYPT';Once with isDone: false, and then with isDone: true
import { type GetResultFromCompletedTaskResponse } from '@iexec/dataprotector';ArrayBuffer
The actual content of the protected file.