fix exam grading
This commit is contained in:
@@ -6,10 +6,14 @@ import { ApiHttpError, apiFetch } from './http'
|
||||
|
||||
const BASE = '/api/v1/role-permission'
|
||||
|
||||
function unwrapData<T>(body: T): T {
|
||||
if (!body || typeof body !== 'object') return body
|
||||
const maybeEnvelope = body as { data?: unknown }
|
||||
return (maybeEnvelope.data as T | undefined) ?? body
|
||||
type DataEnvelope<T> = { data?: T }
|
||||
|
||||
function unwrapData<T>(body: T | DataEnvelope<T>): T {
|
||||
if (body && typeof body === 'object' && 'data' in body) {
|
||||
const data = (body as DataEnvelope<T>).data
|
||||
if (data !== undefined) return data
|
||||
}
|
||||
return body as T
|
||||
}
|
||||
|
||||
export type RoleRow = {
|
||||
|
||||
Reference in New Issue
Block a user