Skip to content

Commit

Permalink
fix: do not wrap array in data object (#965)
Browse files Browse the repository at this point in the history
* fix: do not wrap array in data object

* fix: unwrap
  • Loading branch information
Cafe137 authored Oct 24, 2024
1 parent f0bb1ce commit 6e695b7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 14 deletions.
6 changes: 3 additions & 3 deletions src/modules/grantee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { http } from '../utils/http'
const granteeEndpoint = 'grantee'

export async function getGrantees(reference: string, requestOptions: BeeRequestOptions): Promise<GetGranteesResult> {
const response = await http<GetGranteesResult>(requestOptions, {
const response = await http<string[]>(requestOptions, {
method: 'get',
url: `${granteeEndpoint}/${reference}`,
responseType: 'json',
Expand All @@ -14,7 +14,7 @@ export async function getGrantees(reference: string, requestOptions: BeeRequestO
return {
status: response.status,
statusText: response.statusText,
data: response.data.data,
data: response.data,
}
}

Expand All @@ -26,7 +26,7 @@ export async function createGrantees(
const response = await http<GranteesResult>(requestOptions, {
method: 'post',
url: granteeEndpoint,
data: { grantees: grantees },
data: { grantees },
headers: {
...extractRedundantUploadHeaders(postageBatchId),
},
Expand Down
6 changes: 1 addition & 5 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ import type { HexString } from '../utils/hex'

export * from './debug'

export interface Dictionary<T> {
[Key: string]: T
}

export const SPAN_SIZE = 8
export const SECTION_SIZE = 32
export const BRANCHES = 128
Expand Down Expand Up @@ -145,9 +141,9 @@ export interface UploadResult {
export interface UploadOptions {
/**
* If set to true, an ACT will be created for the uploaded data.
*
*/
act?: boolean

/**
* Will pin the data locally in the Bee node as well.
*
Expand Down
6 changes: 0 additions & 6 deletions src/utils/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ export async function http<T>(options: BeeRequestOptions, config: AxiosRequestCo
maybeRunOnRequestHook(options, requestConfig)
const response = await axios(requestConfig)

// Axios does not parse array of strings as JSON
if (Array.isArray(response.data) && response.data.every(element => typeof element === 'string')) {
const array = response.data as string[]
response.data = { data: array } as any
}

// TODO: https://github.com/axios/axios/pull/6253
return response as AxiosResponse<T>
} catch (e: unknown) {
Expand Down

0 comments on commit 6e695b7

Please sign in to comment.