add request header
This commit is contained in:
parent
0760a53364
commit
850070ed31
|
|
@ -3,6 +3,7 @@ import * as R from 'ramda'
|
|||
import { sprintf } from 'sprintf-js'
|
||||
import request from './request'
|
||||
import HttpMethod from './HttpMethod'
|
||||
import HeadersType from './TypeHeader'
|
||||
|
||||
class ApiMethodFactory {
|
||||
private readonly apiPrefix: string
|
||||
|
|
@ -63,7 +64,7 @@ class ApiMethodFactory {
|
|||
path: pathKeys = [],
|
||||
query: queryKeys = [],
|
||||
}: { path?: string[], query?: string[] } = {},
|
||||
) => async (data: Nullable<T> = null): Promise<R> => {
|
||||
) => async (data: Nullable<T> = null, headers: HeadersType = {}): Promise<R> => {
|
||||
const getBody = R.pipe(
|
||||
R.ifElse(
|
||||
R.isNil,
|
||||
|
|
@ -80,6 +81,7 @@ class ApiMethodFactory {
|
|||
method: method,
|
||||
url: endpoint,
|
||||
data: body,
|
||||
headers: headers,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
interface HeadersType {
|
||||
'Content-Type'?: ContentType
|
||||
Accept?: string
|
||||
}
|
||||
|
||||
export enum ContentType {
|
||||
// MULTIPART = 'multipart/form-data; boundary=boundary',
|
||||
MULTIPART = 'multipart/form-data',
|
||||
JSON = 'application/json',
|
||||
}
|
||||
|
||||
export default HeadersType
|
||||
|
|
@ -7,6 +7,8 @@ const retrieve = async (
|
|||
hasRetriedAfterAuthentication = false,
|
||||
): Promise<any> => {
|
||||
try {
|
||||
console.log(props);
|
||||
|
||||
const { data } = await axios(props)
|
||||
|
||||
return data
|
||||
|
|
|
|||
Loading…
Reference in New Issue