Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rest request with custom headers missing in samples #5

Closed
roman-ponomarenko opened this issue Jun 19, 2017 · 3 comments
Closed

Rest request with custom headers missing in samples #5

roman-ponomarenko opened this issue Jun 19, 2017 · 3 comments

Comments

@roman-ponomarenko
Copy link

Could you possibly add rest request samples with custom headers and with Basic and Bearer support?

@Kinrany
Copy link

Kinrany commented Apr 12, 2019

Did you find them?

https://xkcd.com/979/

@damccorm
Copy link

@Kinrany Not sure if we have samples that illustrate this, but custom headers can be passed in here.

So you would set this up by doing something like:

import * as rm from 'typed-rest-client/RestClient';
import * as hm from 'typed-rest-client/Handlers'

const basicHandler: hm.BasicCredentialHandler = new hm.BasicCredentialHandler(username, password);
const bearerHandler: hm.BearerCredentialHandler = new hm.BearerCredentialHandler(token);
const options: rm.IRequestOptions = <rm.IRequestOptions>({ additionalHeaders: { 'key1': val1, 'key2': val2, ... })
let restc: rm.RestClient = new rm.RestClient('rest-samples', baseUrl, [authHandler, bearerHandler]);
let restRes: rm.IRestResponse<~responseType~> = await restc.get<~responseType~>('get', options);

@Kinrany
Copy link

Kinrany commented Apr 12, 2019

@damccorm thanks :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants