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.js
is built to connect to the XRP Ledger. You won't have much success trying to connect to other services/APIs with xrpl.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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.