getOne: (resource: any, params: any) => {标签:const,封装,any,99,params,key,resource,postgrest,id From: https://blog.51cto.com/u_15460007/6051768
const key: any = Object.keys(params)
const id = params[key[0]];
const primaryKey = getPrimaryKey(resource, primaryKeys);
const query = getQuery(primaryKey, id, resource);
//转换id
const url = `${PostgrestUrl}/${resource}?${query.replace("id", key[0])}&is_delete=eq.0`;
return httpClient(url, {
headers: new Headers({}),
}).then(({ json }) => ({
data: dataWithId(json, primaryKey),
})).catch((err) => {
return err
})
},