I am not sure but try this

import axios,{ AxiosRequestConfig } from 'axios';

const config:AxiosRequestConfig = {
        method: "delete",
        url: url,
        headers: { 
            "Authorization": `Bearer ${elasticPrivateKey}`, 
            "Content-Type": "application/json",
        },
        data: data,
    };
Answer from user14433996 on Stack Overflow
🌐
GitHub
github.com › axios › axios
GitHub - axios/axios: Promise based HTTP client for the browser and node.js · GitHub
2 hours ago - Type` indicates the type of data that the server will respond with // options are: 'arraybuffer', 'document', 'json', 'text', 'stream' // browser only: 'blob' responseType: 'json', // default // `responseEncoding` indicates encoding to use for ...
Starred by 109K users
Forked by 11.6K users
Languages   JavaScript 86.1% | TypeScript 11.9% | HTML 2.0%
Discussions

Axios 1.3.4 typescript error for AxiosRequestConfig
Describe the bug Upgraded to axios 1.3.4 and typescript 4.9.5 and getting TS warning for request headers type Argument of type '(config: InternalAxiosRequestConfig ' is not assignable to parameter of type ... More on github.com
🌐 github.com
20
February 28, 2023
Axios typescript customize AxiosRequestConfig
How can I assign new types on AxiosRequestConfig? something like this axios I don't wanna use the old method like .d.ts. ... You can extend any library types, by using the typescript decleration merging feature. More on stackoverflow.com
🌐 stackoverflow.com
Axios interceptors with Typescript - Stack Overflow
For example, when i create axios instance, i set up default config: More on stackoverflow.com
🌐 stackoverflow.com
reactjs - Axios post request with typescript issue - Stack Overflow
I am trying to add typescript to my current project, so after using it with Axios post request, I am facing an issue. Use case is that I want to send email firstname lastname and password in my post More on stackoverflow.com
🌐 stackoverflow.com
🌐
Geshan
geshan.com.np › blog › 2023 › 11 › axios-typescript
How to use Axios with Typescript a beginner’s guide
November 7, 2023 - That covers the basics of using Axios with TypeScript to make API calls and handle the response data. You have learned the basics of Axios and its types for making a GET and a POST call in a TypeScript environment. The example is executed on a Node.js environment but it should work the same on a browser too as Axios runs on both the server and the client.
🌐
OpenAPI Generator
openapi-generator.tech › docs › generators › typescript-axios
Documentation for the typescript-axios Generator | OpenAPI Generator
February 10, 2026 - These options may be applied as additional-properties (cli) or configOptions (plugins). Refer to configuration docs for more details
🌐
npm
npmjs.com › package › axios
axios - npm
1 week ago - Type` indicates the type of data that the server will respond with // options are: 'arraybuffer', 'document', 'json', 'text', 'stream' // browser only: 'blob' responseType: 'json', // default // `responseEncoding` indicates encoding to use for ...
      » npm install axios
    
Published   Mar 27, 2026
Version   1.14.0
Author   Matt Zabriskie
🌐
GitHub
gist.github.com › JaysonChiang › fa704307bacffe0f17d51acf6b1292fc
Example of Axios with TypeScript · GitHub
@jdriesen This is an example of using axios library. interceptors.request is used to add to each request a Auth header with token. It's part of JWT auth. interseptors.response is used to handle error if some exist after each request. After there is some fetch examples.
🌐
GitHub
github.com › axios › axios › issues › 5573
Axios 1.3.4 typescript error for AxiosRequestConfig · Issue #5573 · axios/axios
February 28, 2023 - Argument of type '(config: InternalAxiosRequestConfig<any>) => AxiosRequestConfig<any>' is not assignable to parameter of type '(value: InternalAxiosRequestConfig<any>) => InternalAxiosRequestConfig<any> | Promise<InternalAxiosRequestConfig<any>>'. Type 'AxiosRequestConfig<any>' is not assignable to type 'InternalAxiosRequestConfig<any> | Promise<InternalAxiosRequestConfig<any>>'. Type 'AxiosRequestConfig<any>' is not assignable to type 'InternalAxiosRequestConfig<any>'. Types of property 'headers' are incompatible.
Author   vishalrajole
🌐
Delft Stack
delftstack.com › home › howto › typescript › axios typescript
How to Use Axios in TypeScript | Delft Stack
February 2, 2024 - This tutorial will use Axios to make REST API calls in TypeScript. The first step is to install Axios in a project. Axios can be installed in a NodeJs or React project. ... Now, Axios can be used in the project with other packages. Several pre-built types are available in the Axios Github repository. This tutorial will focus on some of the important types in Axios. export interface AxiosResponse<T = never> { data: T; status: number; statusText: string; headers: Record<string, string>; config: AxiosRequestConfig<T>; request?: any; }
Find elsewhere
🌐
Petermekhaeil
petermekhaeil.com › til › axios-interceptors
Add custom config to Axios requests
instance.interceptors.response.use(null, function (error) { if (isAxiosError(error)) { console.log(error.config.endpointName); } return Promise.reject(error); }); Create an axios.d.ts and add the custom config under AxiosRequestConfig:
🌐
Altrim
altrim.io › posts › axios-http-client-using-typescript
Axios HTTP Client Using TypeScript - Altrim Beqiri
January 14, 2021 - // http.ts import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from "axios"; enum StatusCode { Unauthorized = 401, Forbidden = 403, TooManyRequests = 429, InternalServerError = 500, } const headers: Readonly<Record<string, string | boolean>> = { Accept: "application/json", "Content-Type": "application/json; charset=utf-8", "Access-Control-Allow-Credentials": true, "X-Requested-With": "XMLHttpRequest", }; // We can use the injectToken function to inject the JWT token through an interceptor // We get the `accessToken` from the `localStorage` which is stored during the authenticati
🌐
Axios
axios-http.com › docs › req_config
Request Config | Axios Docs
... These are the available config options for making requests. Only the url is required. Requests will default to GET if method is not specified. { // `url` is the server URL that will be used for the request url: '/user', // `method` is the request method to be used when making the request method: 'get', // default // `baseURL` will be prepended to `url` unless `url` is absolute. // It can be convenient to set `baseURL` for an instance of axios to pass relative URLs // to methods of that instance.
🌐
Medium
enetoolveda.medium.com › how-to-use-axios-typescript-like-a-pro-7c882f71e34a
How to Use Axios/Typescript like a pro! (axios-es6-class) | by Ernesto Jara Olveda | Medium
May 11, 2020 - first thing is to have axios install along with typescript. ... Now the way to use it is like let’s imagine we have a user api which extends from axios it’ll look like this. import { Api } from "./api"; import { AxiosRequestConfig } from "axios";export class UserApi extends Api { constructor (config: AxiosRequestConfig) { // NEVER FORGET THE SUPER super(config); } }
🌐
Bobby Hadz
bobbyhadz.com › blog › typescript-http-request-axios
Making HTTP requests with Axios in TypeScript | bobbyhadz
February 27, 2024 - What you might have noticed is that axios automatically parses the JSON from the response as opposed to the built-in fetch() method. We directly have the parsed response stored in the data variable. If you want to use the built-in fetch module to make HTTP requests in TypeScript, check out my other article.
🌐
Webdevtutor
webdevtutor.net › blog › typescript-axios-config
Configuring Axios in TypeScript: A Complete Guide
This comprehensive guide provides you with the necessary steps to configure Axios in your TypeScript project successfully.
Top answer
1 of 3
11

There is an ability to set different types to input an output data (axios definitions):

post<T = never, R = AxiosResponse<T>>(url: string, data?: T, config?: AxiosRequestConfig<T>): Promise<R>;

So, in your case it would be something like:

export interface UserRegistrationModel {
  email: string;
  password: string;
  firstname: string;
  lastname: string;
}

export const register = async (user: UserRegistrationModel) => {
  const { data } = await http.post<UserRegistrationModel, AxiosResponse<{ accessToken: string }>>("/users", user);
  return data;
};
2 of 3
2

Change your register function to:

export const register = async (user: UserRegistrationModel) => {
  const { data } = await http.post<AuthModel>("/users", user);
  return data;
};

Also inside your class, the type for post should be:

post<T = any>(
    url: string,
    data?: T,
    config?: AxiosRequestConfig
  ): Promise<T> {
    return this.http.post(url, data, config);
}

Property 'accessToken' does not exist on type 'UserRegistrationModel

You set the return type for data to be UserRegistrationModel, and typescript is telling you that accessToken does not exist on that type. This should be obvious from your definition.

Argument of type '(data: AuthModel) => void' is not assignable to parameter of type '(value: UserRegistrationModel) => void | PromiseLike'. Types of parameters 'data' and 'value' are incompatible. Property 'accessToken' is missing in type 'UserRegistrationModel' but required in type 'AuthModel'.

You are trying to pass a function which expects AuthModel as the only argument, but once again your register function will pass UserRegistrationModel to that function. Typescript is just informing you of this.

🌐
JavaScript in Plain English
javascript.plainenglish.io › axios-a-simple-and-effective-way-to-make-api-calls-in-react-with-typescript-f0b1e7eebdc5
Axios: A Simple and Effective Way to Make API Calls in React with TypeScript | by Damilola Esan | JavaScript in Plain English
November 9, 2023 - The code above creates and configures an axios instance with TypeScript, which you can use to make HTTP requests to the Dog API. The axios instance has some custom settings that apply to all the requests made with it, such as the base URL, the headers, the timeout, and the error handling.
🌐
Xjavascript
xjavascript.com › blog › axiosrequestconfig-typescript
Mastering `AxiosRequestConfig` in TypeScript | XJavaScript.com
July 4, 2025 - This blog post will take you through the fundamentals, usage, common practices, and best practices of AxiosRequestConfig in TypeScript. ... AxiosRequestConfig is an interface in the Axios library that defines the shape of an object used to configure an HTTP request.