Kong / Kong/unirest-nodejs

Are global headers possible?

Open
#110 2 comments 3 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
953
Forks
164
PR merge metrics
No merged PRs in 30d

Description

Hi there, thank you for unirest!

See following example on how we are defining the header information:
```
const unirest = require('unirest');

class RouterService {

private auth = 'Basic sdofihsdfjkn3873kajsd‘;
private dataURL = 'http://backend-xyz‘;

getData() {
return unirest.get(`${dataURL}/data`)
.headers({'Authorization': this.auth});
}

postData() {
return unirest.post(`${dataURL}/data`)
.headers({'Authorization': this.auth});
}

}
```
Is there a way to set the headers information globally? The goal is not to define the header values for each and every request on a express route.

Thank you in advance.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing the unirest.get and unirest.post entry points and how their .headers calls are applied. Compare this with the Express-route usage described in the issue; done means the supported global-header behavior and its request-level interaction are defined, implemented, and tested.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
api, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.