Apify and Crawlee Official Forum

Updated 3 months ago

RequestQueue Issue

I have used this code.
which is provided onsite for example.
Plain Text
// 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.
Attachment
image.png
O
1 comment
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/in_operator_no_object

maybe try this:
Plain Text
// 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,
});
Add a reply
Sign up and join the conversation on Discord