Search code examples
javascriptnode.jsapify

Why is "context.Apify" undefined


I'm trying to learn how to use request in Apify Web-Scraper Actor, I don't understand how it works.

I first did this with Postman, I did get the result I wanted, now I want to do the same on Apify.

async function pageFunction(context) {...
    const request = new context.Apify.Request({
        url:...
        headers: { Accept: 'application/json' },
        method: 'POST',
        payload:{...}
    })
}

I would like to get a Json files corresponding to this request. Instead I get an error : "Cannot read property 'Request' of undefined"


Solution

  • context.Apify is only available in Puppeteer Scraper, not in Web Scraper. Web Scraper is just a simple in-browser interface so porting all Apify functions into the browser would be almost impossible.