usebruno / bruno

Opensource IDE For Exploring and Testing Api's (lightweight alternative to postman/insomnia)
https://www.usebruno.com/
MIT License
26.07k stars 1.2k forks source link

[Feature] Provide well configured axios instance to pre-/post custom scripts #1349

Open mirkogolze opened 9 months ago

mirkogolze commented 9 months ago

Before running any request a complex logic retrieving proxy and ca-configuration is done out of the global and collection level configuration. When I use axios inside a custom javascript I can't benefit of this nice pre-work configuring axios.

It would be grateful to have a mechanism to benefit of the pre-configured axios instance.

E.g. get the instance via require.

  const axiosinstance = require('axiosintance');

or get access to the instance via bru-Object

  bru.getAxiosInstance();
martinsefcik commented 9 months ago

Wouldn't it be better to provide something similar as pm.sendRequest() in Postman. So e.g. bru.sendRequest() and it would be wrapper around Axios request with everything like proxy, certs, ... configured. This would be more stable for example if hypothetically Bruno will be changed in the future and Axios will be internally changed to some other HTTP client then it does not affect thousands of user's collections.