warmuuh/milkman

response body scripting broken on macos

Closed this issue · 7 comments

Hi,

In milkman on MacOS, it's not possible to use scripting with responses in the "AfterRequest" with GRPC. Body is null.

If I use the example from scripting/readme.md I get the following:
image

unluckily, it is called payload.payload for grpc
see https://github.com/warmuuh/milkman/blob/master/milkman-grpc/src/main/java/milkman/plugin/grpc/domain/GrpcPayloadAspect.java for reference (name of the aspect = "payload", property-name: "payload")
hope, it helps

EDIT: will note down to improve documentation on accessing various things in scripting

thanks a lot for the fast reply, but this also doesn't seem to help, am I missing something.

When I do a console.log of response.payload it is null. However, I can see the response payload in the viewer.

EDIT:
I get the js error even before I get the response, it's like the "After Request" script fires immediately, without waiting for the response.

image

yeah, two things: i mixed up request vs response, the right code would be console.log(JSON.parse(milkman.response.Payload.payloads).url), but this didnt work (some regression). i fixed it right now (1ee9682) so nightly version contains the fix (in some minutes).
(verified the fix locally, so it should work :D)

created follow-up: #171

works, thank you for the fast fix!

for later reference: i added some generated api docs: https://github.com/warmuuh/milkman/blob/master/docs/script-api.md

Very nice, I also saw it in the other PR.

One thing I would have really liked when I first discovered milkman is more scripting examples in the docs. Other than that great tool and thanks for your work!