Skip to content

Crawlee—A web scraping and browser automation library for Node.js to build reliable crawlers. In JavaScript and TypeScript. Extract data for AI, LLMs, RAG, or GPTs. Download HTML, PDF, JPG, PNG, and other files from websites. Works with Puppeteer, Playwright, Cheerio, JSDOM, and raw HTTP. Both headful and headless mode. With proxy rotation.

Rmeoving rawBody parameter

Marek Trunkatca0f7342f1d7
diff --git a/src/actor.js b/src/actor.js
index ba1bb47f7..3f3fcb959 100644
--- a/src/actor.js
+++ b/src/actor.js
@@ -123,12 +123,14 @@ export const getValue = (key, callback = null) => {
promise = newPromise()
.then(() => {
- return apifyClient.keyValueStores.getRecord({
- storeId,
- promise: promisePrototype,
- key,
- rawBody: true,
- });
+ return apifyClient
+ .keyValueStores
+ .getRecord({
+ storeId,
+ promise: promisePrototype,
+ key,
+ })
+ .then(output => output ? output.body : null);
});
}
@@ -401,7 +403,6 @@ export const readyFreddy = () => {
* @param {String} [opts.timeoutSecs] - Time limit for act to finish. If limit is reached then run in RUNNING status is returned.
Default is unlimited.
* @param {String} [opts.fetchOutput] - If false then doesn't fetch the OUTPUT from key-value store. Default is true.
- * @param {String} [opts.rawBody] - If true then returns only OUTPUT value without content type and other info. Default is false.
* @param {String} [opts.disableBodyParser] - If true then doesn't parse the body - ie. JSON to object. Default is false.
*/
export const call = (actId, input, opts = {}) => {
@@ -452,14 +453,12 @@ export const call = (actId, input, opts = {}) => {
const timeoutAt = timeoutSecs ? Date.now() + (timeoutSecs * 1000) : null;
// GetRecord() options.
- const { rawBody, disableBodyParser } = opts;
- checkParamOrThrow(rawBody, 'rawBody', 'Maybe Boolean');
+ const { disableBodyParser } = opts;
checkParamOrThrow(disableBodyParser, 'disableBodyParser', 'Maybe Boolean');
// Adds run.output field to given run and returns it.
const addOutputToRun = (run) => {
const getRecordOpts = { key: 'OUTPUT', storeId: run.defaultKeyValueStoreId };
- if (rawBody) getRecordOpts.rawBody = rawBody;
if (disableBodyParser) getRecordOpts.disableBodyParser = disableBodyParser;
return keyValueStores
diff --git a/test/actor.js b/test/actor.js
index 1766a3b8f..8d0c930d0 100644
--- a/test/actor.js
+++ b/test/actor.js
@@ -964,7 +964,7 @@ describe('Apify.call()', () => {
const finishedRun = Object.assign({}, run, { status: ACT_TASK_STATUSES.SUCCEEDED });
const input = 'something';
const contentType = 'text/plain';
- const output = 'some-output';
+ const output = { contentType, body: 'some-output' };
const expected = Object.assign({}, finishedRun, { output });
const build = 'xxx';
@@ -984,12 +984,12 @@ describe('Apify.call()', () => {
const keyValueStoresMock = sinon.mock(Apify.client.keyValueStores);
keyValueStoresMock.expects('getRecord')
- .withExactArgs({ storeId: run.defaultKeyValueStoreId, key: 'OUTPUT', rawBody: true, disableBodyParser: true })
+ .withExactArgs({ storeId: run.defaultKeyValueStoreId, key: 'OUTPUT', disableBodyParser: true })
.once()
.returns(Promise.resolve(output));
return Apify
- .call(actId, input, { contentType, token, rawBody: true, disableBodyParser: true, build })
+ .call(actId, input, { contentType, token, disableBodyParser: true, build })
.then((callOutput) => {
expect(callOutput).to.be.eql(expected);
keyValueStoresMock.restore();
@@ -1005,7 +1005,7 @@ describe('Apify.call()', () => {
const runningRun = Object.assign({}, run, { status: 'RUNNING' });
const finishedRun = Object.assign({}, run, { status: ACT_TASK_STATUSES.SUCCEEDED });
const input = { a: 'b' };
- const output = 'some-output';
+ const output = { body: 'some-output' } ;
const expected = Object.assign({}, finishedRun, { output });
const build = 'xxx';
@@ -1025,12 +1025,12 @@ describe('Apify.call()', () => {
const keyValueStoresMock = sinon.mock(Apify.client.keyValueStores);
keyValueStoresMock.expects('getRecord')
- .withExactArgs({ storeId: run.defaultKeyValueStoreId, key: 'OUTPUT', rawBody: true, disableBodyParser: true })
+ .withExactArgs({ storeId: run.defaultKeyValueStoreId, key: 'OUTPUT', disableBodyParser: true })
.once()
.returns(Promise.resolve(output));
return Apify
- .call(actId, input, { token, rawBody: true, disableBodyParser: true, build })
+ .call(actId, input, { token, disableBodyParser: true, build })
.then((callOutput) => {
expect(callOutput).to.be.eql(expected);
keyValueStoresMock.restore();