Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: do not wrap array in data object #965

Merged
merged 2 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading