refactor: remove accessToken from parameters in API requests for cleaner handling

This commit is contained in:
Ardeman
2025-03-09 10:34:25 +08:00
parent d38bf3a705
commit 9976626f97
7 changed files with 33 additions and 38 deletions
+9 -9
View File
@@ -15,16 +15,16 @@ type TParameter = {
}
export const createNewsRequest = async (parameters: TParameter) => {
const { accessToken, payload } = parameters
const { payload, ...restParameters } = parameters
const { categories, tags, live_at, ...restPayload } = payload
const transformedPayload = {
...restPayload,
categories: categories.map((category) => category?.id),
tags: tags?.map((tag) => tag?.id) || [],
live_at: new Date(live_at).toISOString(),
}
try {
const { categories, tags, ...restPayload } = payload
const transformedPayload = {
...restPayload,
categories: categories.map((category) => category?.id),
tags: tags?.map((tag) => tag?.id) || [],
live_at: new Date(payload?.live_at).toISOString(),
}
const { data } = await HttpServer({ accessToken }).post(
const { data } = await HttpServer(restParameters).post(
'/api/news/create',
transformedPayload,
)