Get the dataset from the apify-js API client based on the actorRunId?

Is it possible? I can only find actorClient.lastRun() This seems an extremely obvious use case. I did find it here https://docs.apify.com/api/v2#/reference/actor-runs/run-collection/get-dataset but that seems to be for URL's only.
3 Replies
Pepa J
Pepa J2y ago
Hi @Moby It is possible to get to the dataset based on runId :
import { Actor } from 'apify';

(await Actor.apifyClient.run('887a7fecbca').dataset().get()).forEach((item) => {
console.log(item);
});
import { Actor } from 'apify';

(await Actor.apifyClient.run('887a7fecbca').dataset().get()).forEach((item) => {
console.log(item);
});
Is this what you had in mind?
overseas-lavender
overseas-lavenderOP2y ago
@Pepa J Thank you I figured it out, not entirely how you mentioned it though. First of all I was referring to the "apify-client" Javascript client. In that client, I think I got it to work by doing const { items } = await apify.run(actorRunId).dataset().listItems()
Pepa J
Pepa J2y ago
Yep, thast is also a way. I am glad it works for you!

Did you find this page helpful?