Skip to content

Commit

Permalink
[Feat]#44 QuestionData 선언 및 데이터 구조 변경에 따른 코드 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
choiyoubin committed Dec 17, 2024
1 parent b3360a4 commit afa4683
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ struct BaseResponse<T: Codable>: Codable {
let data: T?
}

struct QuestionData: Codable {
let questionId: Int
let questions: [String]
}

/// data가 없는 API 통신에서 사용할 BlankData 구조체
struct BlankData: Codable {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,13 @@ extension InputViewController {
switch result {
case .success(let response):
do {
let responseData = try response.map(BaseResponse<[String]>.self)
let responseData = try response.map(BaseResponse<QuestionData>.self)

if responseData.status == 200 {
if let data = responseData.data {
if let data = responseData.data
{
print("질문지를 성공적으로 불러왔습니다. 질문목록: \(data)")
completion(.success(data))
completion(.success(data.questions))
} else {
print("응답에서 질문 목록울 찾을 수 없습니다.")
completion(.failure(.networkFail))
Expand Down

0 comments on commit afa4683

Please sign in to comment.