When POSTing to an URL with an unsupported protocol, the beforeError
hook is not called.
The beforeError
hook should be called just like with other errors, e.g. ERR_NON_2XX_3XX_RESPONSE
.
import got from "got";
const redactAuthorizationHeader = (error) => {
error.options.headers.authorization = "<redacted>";
error.options._init[0].headers.authorization = "<redacted>";
return error;
};
const post = (payload) =>
got
.post(`xhttps://www.example.com/some/resource`, {
headers: { authorization: `Bearer secret` },
json: payload,
hooks: { beforeError: [redactAuthorizationHeader] },
})
.json();
await post({ foo: 42 });
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too