🐛 Fix payload case issue
This commit is contained in:
parent
bf43234eae
commit
7e0dff9f0f
@ -38,7 +38,7 @@
|
||||
"remark-parse": "^11.0.0",
|
||||
"remark-rehype": "^11.1.1",
|
||||
"sitemap": "^8.0.0",
|
||||
"solar-js-sdk": "^0.1.1",
|
||||
"solar-js-sdk": "^0.1.2",
|
||||
"unified": "^11.0.5",
|
||||
"zustand": "^5.0.3"
|
||||
},
|
||||
|
@ -8,7 +8,7 @@
|
||||
"name": "LittleSheep",
|
||||
"email": "littlesheep.code@hotmail.com"
|
||||
},
|
||||
"version": "0.1.1",
|
||||
"version": "0.1.2",
|
||||
"tsup": {
|
||||
"entry": [
|
||||
"src/index.ts"
|
||||
|
@ -15,18 +15,18 @@ function toCamelCase(obj: any): any {
|
||||
return obj
|
||||
}
|
||||
|
||||
// function toSnakeCase(obj: any): any {
|
||||
// if (Array.isArray(obj)) {
|
||||
// return obj.map(toSnakeCase)
|
||||
// } else if (obj && typeof obj === 'object') {
|
||||
// return Object.keys(obj).reduce((result: any, key) => {
|
||||
// const snakeKey = key.replace(/[A-Z]/g, (char) => `_${char.toLowerCase()}`)
|
||||
// result[snakeKey] = toSnakeCase(obj[key])
|
||||
// return result
|
||||
// }, {})
|
||||
// }
|
||||
// return obj
|
||||
// }
|
||||
function toSnakeCase(obj: any): any {
|
||||
if (Array.isArray(obj)) {
|
||||
return obj.map(toSnakeCase)
|
||||
} else if (obj && typeof obj === 'object') {
|
||||
return Object.keys(obj).reduce((result: any, key) => {
|
||||
const snakeKey = key.replace(/[A-Z]/g, (char) => `_${char.toLowerCase()}`)
|
||||
result[snakeKey] = toSnakeCase(obj[key])
|
||||
return result
|
||||
}, {})
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
const baseURL = 'https://api.sn.solsynth.dev'
|
||||
|
||||
@ -43,6 +43,19 @@ export const sni: AxiosInstance = (() => {
|
||||
},
|
||||
(error) => error,
|
||||
)
|
||||
|
||||
/// Case convertor
|
||||
|
||||
inst.interceptors.request.use(
|
||||
(config) => {
|
||||
if (config.data) {
|
||||
config.data = toSnakeCase(config.data)
|
||||
}
|
||||
return config
|
||||
},
|
||||
(error) => Promise.reject(error),
|
||||
)
|
||||
|
||||
inst.interceptors.response.use(
|
||||
(response) => {
|
||||
if (response.data) {
|
||||
|
@ -12,7 +12,7 @@ export const getServerSideProps: GetServerSideProps = (async (context) => {
|
||||
|
||||
return getConsoleStaticProps({
|
||||
props: {
|
||||
title: `Edit Release "${data.name}"`,
|
||||
title: `Edit Release v${data.version}`,
|
||||
release: data,
|
||||
},
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user