How to use the got.mergeOptions function in got

To help you get started, we’ve selected a few got examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sindresorhus / gh-got / index.js View on Github external
const create = () => got.create({
	options: got.mergeOptions(got.defaults.options, {
		json: true,
		token: process.env.GITHUB_TOKEN,
		baseUrl: process.env.GITHUB_ENDPOINT || 'https://api.github.com',
		headers: {
			accept: 'application/vnd.github.v3+json',
			'user-agent': 'https://github.com/sindresorhus/gh-got'
		}
	}),

	methods: got.defaults.methods,

	handler: (options, next) => {
		if (options.token) {
			options.headers.authorization = options.headers.authorization || `token ${options.token}`;
		}
github project-flogo / flogo-web / apps / server / src / api / v2 / runner / services / base-client.ts View on Github external
export function createBaseClient() {
  return got.create({
    options: got.mergeOptions(got.defaults.options, { json: true }),
    methods: got.defaults.methods,
    handler: requestLogger,
  });
}
github poketo / poketo / src / get.js View on Github external
export function setDefaultHeaders(headers: Object) {
  instance.defaults.options = got.mergeOptions(
    instance.defaults.options,
    { headers },
  );
}