Skip to content

Commit

Permalink
Update server.ts
Browse files Browse the repository at this point in the history
It's odd to compare the length with 0. In the original code, I need to do this to add a custom header:

let custom_header = {};
let server = new Server('https://url_to_server', {headers: custom_header});
custom_header['MyHeader'] = 'Some header content';

Shouldn't it check for non-zero to add the custom header?
  • Loading branch information
celestialkylin committed Jun 11, 2024
1 parent e5e49dc commit ba29d60
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/rpc/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class Server {
constructor(serverURL: string, opts: Server.Options = {}) {
this.serverURL = URI(serverURL);

if (opts.headers && Object.keys(opts.headers).length === 0) {
if (opts.headers && Object.keys(opts.headers).length !== 0) {
AxiosClient.interceptors.request.use((config: any) => {
// merge the custom headers into any existing headers
config.headers = Object.assign(config.headers, opts.headers);
Expand Down

0 comments on commit ba29d60

Please sign in to comment.