make a http request with a custom header in typescript

import axios, { AxiosRequestConfig } from 'axios';

const config: AxiosRequestConfig = {
  headers: { 'Custom-Header': 'Some value' },

axios.get('', config)
  .then(response => {
  .catch(error => {
298 chars
14 lines

The header field in the config object can be used to specify any custom headers that need to be sent with the request. In this case, the Custom-Header with a value of Some value is being sent along with the GET request to

The axios library is being used here for making the HTTP request. It is a popular client for making HTTP requests in JavaScript/TypeScript.

gistlibby LogSnag