CA
Crawlee & Apify9mo ago
adverse-sapphire

RequestQueue Issue

I have used this code. which is provided onsite for example.
// Import the JavaScript SDK into your project
import { Actor } from 'apify';

await Actor.init();
// ...

const queue = await Actor.openRequestQueue();

// Enqueue requests
await queue.addRequests([{ url: 'http://example.com/aaa' }]);
await queue.addRequests(['http://example.com/foo', 'http://example.com/bar'], {
forefront: true,
});

// Get the next request from queue
const request1 = await queue.fetchNextRequest();
const request2 = await queue.fetchNextRequest();

// Get a specific request
const specificRequest = await queue.getRequest('shi6Nh3bfs3');

// Reclaim a failed request back to the queue
// and process it again
await queue.reclaimRequest(request2);

// Remove a queue
await queue.drop();

// ...
await Actor.exit();
// Import the JavaScript SDK into your project
import { Actor } from 'apify';

await Actor.init();
// ...

const queue = await Actor.openRequestQueue();

// Enqueue requests
await queue.addRequests([{ url: 'http://example.com/aaa' }]);
await queue.addRequests(['http://example.com/foo', 'http://example.com/bar'], {
forefront: true,
});

// Get the next request from queue
const request1 = await queue.fetchNextRequest();
const request2 = await queue.fetchNextRequest();

// Get a specific request
const specificRequest = await queue.getRequest('shi6Nh3bfs3');

// Reclaim a failed request back to the queue
// and process it again
await queue.reclaimRequest(request2);

// Remove a queue
await queue.drop();

// ...
await Actor.exit();
I am getting this error.
No description
2 Replies
Hall
Hall9mo ago
View post on community site
This post has been pushed to the community knowledgebase. Any replies in this thread will be synced to the community site.
Apify Community
rare-sapphire
rare-sapphire9mo ago
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/in_operator_no_object maybe try this:
// instead of:
await queue.addRequests(['http://example.com/foo', 'http://example.com/bar'], {
forefront: true,
});

// try to add Request object (https://crawlee.dev/api/core/class/Request):

await queue.addRequests([
{
url: 'http://example.com/foo',
},
{
url: 'http://example.com/bar'
}
], {
forefront: true,
});
// instead of:
await queue.addRequests(['http://example.com/foo', 'http://example.com/bar'], {
forefront: true,
});

// try to add Request object (https://crawlee.dev/api/core/class/Request):

await queue.addRequests([
{
url: 'http://example.com/foo',
},
{
url: 'http://example.com/bar'
}
], {
forefront: true,
});

Did you find this page helpful?