Call elasticsearch API from custom Kibana plugin with relative url

I thought of using it this way as the last option. If there is no other way I may use axios to call this API.
but there is issue with this approach.
as elasticsearch API needs username/password, this API will print ouput for the user I have used to access API and not for the user logged in from kibana.