I need to set custom headers for my requests in xrpl.js in order to connect to a Blockchain Service with an API Key. I see that ConnectionOptions has an authorization field, which then is used as
options.headers = { Authorization: `Basic ${base64}` }
in createWebSocket, but my service requires
options.headers = { 'x-api-key': '<My API Key>' }
Is there any way to do that?
xrpl.jsis built to connect to the XRP Ledger. You won't have much success trying to connect to other services/APIs withxrpl.js.The best way is to use a different library for such connections. There are many other libraries which lets you connect to APIs, such as
node-fetch. They will also allow you to set custom headers.