本文整理汇总了TypeScript中wherehows-web/utils/api/fetcher.getJSON函数的典型用法代码示例。如果您正苦于以下问题:TypeScript getJSON函数的具体用法?TypeScript getJSON怎么用?TypeScript getJSON使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getJSON函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: async
const readComplianceDataTypes = async (): Promise<Array<IComplianceDataType>> => {
const { complianceDataTypes = [] } = await getJSON<IComplianceDataTypeResponse>({
url: complianceDataTypesUrl
});
return complianceDataTypes;
};
示例2: async
const readDatasetView = async (id: number): Promise<IDatasetView> => {
const { status, dataset } = await getJSON<IDatasetViewGetResponse>({ url: datasetViewUrlById(id) });
if (status === ApiStatus.OK && dataset) {
return dataset;
}
throw new Error(datasetApiException);
};
示例3: async
const readDatasetRetentionByUrn = async (urn: string): Promise<IGetDatasetRetentionResponse | null> => {
try {
return await getJSON<IGetDatasetRetentionResponse>({ url: datasetRetentionUrlByUrn(urn) });
} catch (e) {
if (isNotFoundApiError(e)) {
return null;
}
throw e;
}
};
示例4: async
export const readDatasetHealthByUrn = async (urn: string): Promise<IDatasetHealth> => {
const defaultResponse = { score: 0, validations: [] };
try {
const { health } = await getJSON<IHealthScoreResponse>({ url: datasetHealthUrlByUrn(urn) });
return health;
} catch {
return defaultResponse;
}
};
示例5: async
const readDatasetSchemaComments = async (datasetId: number, columnId: number): Promise<Array<IDatasetComment>> => {
const defaultData: { comments: Array<IDatasetComment> } = { comments: [] };
const { status, data: { comments = [] } = defaultData } = await getJSON<IDatasetCommentsGetResponse>({
url: datasetSchemaCommentUrlById(datasetId, columnId)
});
if (status === ApiStatus.OK) {
return comments;
}
throw new Error('');
};
示例6: async
const readComplianceDataTypes = async (): Promise<Array<IComplianceDataType>> => {
let complianceDataTypes: Array<IComplianceDataType> = [];
try {
({ complianceDataTypes = [] } = await getJSON<IComplianceDataTypeResponse>({
url: complianceDataTypesUrl
}));
} catch {
//no-op
}
return complianceDataTypes;
};
示例7: async
const readDatasetAcls = async (urn: string): Promise<Array<IAccessControlEntry>> => {
let acls: Array<IAccessControlEntry> = [];
try {
return getJSON<IGetAclsResponse>({ url: datasetAclsUrlByUrn(urn) });
} catch (e) {
if (isNotFoundApiError(e)) {
return acls;
}
throw e;
}
};
示例8: async
const readDatasetSchemaByUrn = async (urn: string): Promise<IDatasetSchema> => {
let schema: IDatasetSchema;
try {
({ schema } = await getJSON<IDatasetSchemaGetResponse>({ url: datasetSchemaUrlByUrn(urn) }));
} catch {
return {
schemaless: false,
rawSchema: null,
keySchema: null,
columns: []
};
}
return schema;
};