bruno icon indicating copy to clipboard operation
bruno copied to clipboard

script PostResponse: res is not a function

Open gmajcen opened this issue 2 years ago • 4 comments

tried to save some ids to var in Post Response under scripts: const ids = res('features.id')

Error: Error invoking remote method 'send-http-request': TypeError: res is not a function

the same thing works with Vars.

gmajcen avatar Oct 09 '23 13:10 gmajcen

@gmajcen Yup, I am able to reproduce the bug. Will get this fixed.

Meanwhile, here is a workaround.

const {get} = require('lodash');

const page = get(res.getBody(), 'page');
console.log('page', page)

image

helloanoop avatar Oct 09 '23 14:10 helloanoop

I created https://github.com/usebruno/bruno/pull/579 to fix it. It works on my machine 😄

armand-janssen avatar Oct 13 '23 17:10 armand-janssen

Hello, I have the same problem (v1.2.0). Any updates on this @helloanoop ?

It seems somewhat misleading from a user's perspective because the documentation explicitly states that the feature works but it does not. Tell me if I can do anything to help 😄

Note: the workaround mentionned works fine

doliG avatar Nov 21 '23 16:11 doliG

The res object doesn't seem to be created at all.

marshall-davis avatar May 09 '24 15:05 marshall-davis

The fix doesn't work, I am still getting 'Error invoking remote method 'send-http-request': TypeError: res is not a function' on the latest Bruno version.

angiurgiu avatar Sep 05 '24 17:09 angiurgiu

@anusreesubash Please work with @sanjai0py and prioritise reviewing the PR #579

The res property should be a function which uses a custom query parser maintained by us - see https://docs.usebruno.com/scripting/response/response-query

helloanoop avatar Sep 06 '24 09:09 helloanoop