Skip to content

Commit

Permalink
PP-11844 Fix type errors for upgrading to axios 1.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
stephencdaly committed Nov 13, 2023
1 parent 7043382 commit b0cec80
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/lib/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@ export class EntityNotFoundError extends RequestError {
}
}

export interface ErrorData {
errors?: string[]
}

// wrap errors from other frameworks in a format that this service can report on
// @FIXME(sfount) stack trace isn't respected
export class RESTClientError extends Error {
public name: string

public data: AxiosError
public data: AxiosError<ErrorData>

public service: string

Expand Down
13 changes: 10 additions & 3 deletions src/lib/pay-request/base.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import http from 'http'
import https from 'https'
import axios, {AxiosInstance, AxiosResponse, AxiosError, AxiosRequestConfig, Method} from 'axios'
import axios, {
AxiosInstance,
AxiosResponse,
AxiosError,
AxiosRequestConfig,
Method,
InternalAxiosRequestConfig
} from 'axios'
import {App} from './shared'

const {RESTClientError} = require('../errors')
Expand Down Expand Up @@ -41,7 +48,7 @@ export default class Client {
'Content-Type': 'application/json'
},
})
this._axios.interceptors.request.use((request): AxiosRequestConfigWithMetadata => {
this._axios.interceptors.request.use((request) => {
const headers = options.transformRequestAddHeaders ? options.transformRequestAddHeaders() : {}
Object.entries(headers)
.forEach(([headerKey, headerValue]) => {
Expand Down Expand Up @@ -103,7 +110,7 @@ export interface PayRequestContext {
status?: number;
url?: string;
code?: number | string;
method?: Method;
method?: Method | string;
}

interface AxiosRequestConfigWithMetadata extends AxiosRequestConfig {
Expand Down

0 comments on commit b0cec80

Please sign in to comment.