Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
meanspec-frontend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MeanSpec (SCE338 2024-2 Group 1)
meanspec-frontend
Commits
85ced969
There was an error fetching the commit references. Please try again later.
Commit
85ced969
authored
5 months ago
by
정원제
🎸
Browse files
Options
Downloads
Patches
Plain Diff
chore: eslint에 맞게 error를 throw하게 변경
parent
54172dba
No related branches found
No related tags found
No related merge requests found
Pipeline
#10795
passed
5 months ago
Stage: package
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/api/my/updatePCName.js
+18
-33
18 additions, 33 deletions
src/api/my/updatePCName.js
with
18 additions
and
33 deletions
src/api/my/updatePCName.js
+
18
−
33
View file @
85ced969
import
axios
from
'
../axios
'
;
const
updatePCName
=
async
(
pcId
,
newName
)
=>
{
console
.
log
(
pcId
,
newName
);
try
{
// 입력값 검증
if
(
!
newName
||
!
newName
.
trim
())
{
throw
{
response
:
{
data
:
{
message
:
"
잘못된 요청입니다
"
,
statusCode
:
400
,
data
:
{
error
:
"
이름은 필수 입력값입니다
"
}
}
}
};
}
const
response
=
await
axios
.
patch
(
`/my/pc/
${
pcId
}
/name`
,
{
name
:
newName
.
trim
()
});
// 성공 응답 형식에 맞춤
return
{
message
:
"
PC 이름이 성공적으로 변경되었습니다
"
,
statusCode
:
200
,
data
:
{
id
:
pcId
,
name
:
newName
,
updatedAt
:
new
Date
().
toISOString
()
}
};
return
response
.
data
;
}
catch
(
error
)
{
// 401 Unauthorized 에러 처리
if
(
error
.
response
?.
status
===
401
)
{
throw
{
const
unauthorizedError
=
new
Error
(
"
인증되지 않은 요청입니다
"
);
unauthorizedError
.
response
=
{
data
:
{
message
:
"
인증되지 않은 요청입니다
"
,
statusCode
:
401
,
data
:
{}
}
};
throw
unauthorizedError
;
}
// 400 Bad Request 에러 처리
if
(
error
.
response
?.
status
===
400
)
{
throw
{
const
badRequestError
=
new
Error
(
"
잘못된 요청입니다
"
);
badRequestError
.
response
=
{
data
:
{
message
:
"
잘못된 요청입니다
"
,
statusCode
:
400
,
data
:
{
error
:
"
이름은 필수 입력값입니다
"
}
}
};
throw
badRequestError
;
}
// 기타 에러는 그대로 전달
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment