insomnia icon indicating copy to clipboard operation
insomnia copied to clipboard

Can't get response body with `context.response.getBody()` in plugin

Open stamaimer opened this issue 1 year ago • 2 comments

Expected Behavior

I had wrote a local plugin to post-process response. The code as follows:

        const respBody = context.response.getBody();
        console.log("respBody", respBody.toString('utf-8'));

        rspObj = JSON.parse(respBody.toString('utf-8'));
        console.log("rspObj", rspObj);

After update insomnia version, When i send request as usual, the plugin throw a error Response hook failed SyntaxError: Unexpected token 'o', "[object Promise]" is not valid JSON

The respBody.toString('utf-8') turn to [object Promise] instead of the original response body buffer.

How can i get the original response body buffer in the new version insomnia?

Actual Behavior

The respBody.toString('utf-8') turn to [object Promise] instead of the original response body buffer.

Reproduction Steps

No response

Is there an existing issue for this?

Which sync method do you use?

  • [ ] Git sync.
  • [ ] Insomnia Cloud sync.
  • [x] Local only

Additional Information

No response

Insomnia Version

Insomnia 11.0.1

What operating system are you using?

macOS

Operating System Version

Darwin arm64 24.0.0

Installation method

download from insomnia.rest

Last Known Working Insomnia version

No response

stamaimer avatar Mar 28 '25 09:03 stamaimer

https://github.com/Kong/insomnia/issues/8479

stamaimer avatar Mar 28 '25 09:03 stamaimer

#8479

Closing, we are tracking this issue in #8479

notjaywu avatar Apr 02 '25 06:04 notjaywu