Skip to content

Commit

Permalink
Old axios versions don't have Method type
Browse files Browse the repository at this point in the history
  • Loading branch information
cretueusebiu committed Apr 29, 2021
1 parent a420a5e commit 6bc3563
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/Form.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import axios, { Method, AxiosInstance, AxiosRequestConfig, AxiosResponse, AxiosError } from 'axios'
import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse, AxiosError } from 'axios'
import Errors from './Errors'
import { deepCopy } from './util'

Expand Down Expand Up @@ -148,7 +148,7 @@ class Form {
/**
* Submit the form data via an HTTP request.
*/
submit (method: Method, url: string, config: AxiosRequestConfig = {}): Promise<AxiosResponse> {
submit (method: string, url: string, config: AxiosRequestConfig = {}): Promise<AxiosResponse> {
this.startProcessing()

if (method.toLowerCase() === 'get') {
Expand All @@ -158,6 +158,7 @@ class Form {
}

return new Promise((resolve, reject) => {
// @ts-ignore
(Form.axios || axios).request({ url: this.route(url), method, ...config })
.then((response: AxiosResponse) => {
this.finishProcessing()
Expand Down
4 changes: 2 additions & 2 deletions types/Form.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Method, AxiosInstance, AxiosRequestConfig, AxiosResponse, AxiosError } from 'axios';
import { AxiosInstance, AxiosRequestConfig, AxiosResponse, AxiosError } from 'axios';
import Errors from './Errors';
declare class Form {
[key: string]: any;
Expand Down Expand Up @@ -82,7 +82,7 @@ declare class Form {
/**
* Submit the form data via an HTTP request.
*/
submit(method: Method, url: string, config?: AxiosRequestConfig): Promise<AxiosResponse>;
submit(method: string, url: string, config?: AxiosRequestConfig): Promise<AxiosResponse>;
/**
* Handle the errors.
*/
Expand Down

0 comments on commit 6bc3563

Please sign in to comment.