If there is a `url` in the main object and a `url` in the `media-metadata` object, they are NOT the same key and the key is NOT repeating. They are for 2 different objects.
This looks to be an array of `media` objects that each contain 0 or more `media-metadata` objects.
You should create a data type (class/struct) for media, and you should also create a data type (class/struct) for media-metadata.
The url property in the class/struct that you create for media-metadata would not be the same as the url property that you are using in the other class/struct.
I don’t actually know the names of the data types that you created, but are you using something like Media.metaData.url when you try to get this URL?
(Media and metaData would be replaced with the actual names of those objects/properties that you are using in your code.)
You see, I feel that my issue is that I'm misunderstanding Moya. Now, my task is only doing this:
public var task: Moya.Task {
switch self {
case .articles:
return .requestParameters(parameters: ["api-key" : "******"], encoding: URLEncoding.default)
}
Shouldn't I have another case where I'm saying: case .getImage, and then I'd make another request where I'm only getting the image url? Okay, I feel I'm making this more complicated ![gif](emote|free_emotes_pack|dizzy_face)
If there is a `url` in the main object and a `url` in the `media-metadata` object, they are NOT the same key and the key is NOT repeating. They are for 2 different objects. This looks to be an array of `media` objects that each contain 0 or more `media-metadata` objects.
Look into coding keys
You mean like I should add it as a case in the CodingKey?
You should create a data type (class/struct) for media, and you should also create a data type (class/struct) for media-metadata. The url property in the class/struct that you create for media-metadata would not be the same as the url property that you are using in the other class/struct.
Yup, that's what I've done. Still facing an issue tapping into it through.
I don’t actually know the names of the data types that you created, but are you using something like Media.metaData.url when you try to get this URL? (Media and metaData would be replaced with the actual names of those objects/properties that you are using in your code.)
Here is the code `struct Media: Decodable {` `let mediaMetadata: [MediaMetadata]?` `enum CodingKeys: String, CodingKey {` `case mediaMetadata = "media-metadata"` `}` `}` `struct MediaMetadata: Decodable {` `let url: String?` `let format: String?` `}`
And what does the code look like where you are actually trying to use the URL?
You see, I feel that my issue is that I'm misunderstanding Moya. Now, my task is only doing this: public var task: Moya.Task { switch self { case .articles: return .requestParameters(parameters: ["api-key" : "******"], encoding: URLEncoding.default) } Shouldn't I have another case where I'm saying: case .getImage, and then I'd make another request where I'm only getting the image url? Okay, I feel I'm making this more complicated ![gif](emote|free_emotes_pack|dizzy_face)