Skip to content

Commit 447d1e7

Browse files
authored
Added expander example
1 parent 496a8d1 commit 447d1e7

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,31 @@ Information about Filtering and the postfixes like 'not_in' can be found [here](
110110
The rest of the available Endpoints are [Available Here](https://igdb.github.io/api/endpoints/).
111111
The IGDB API documentation provides [details on search parameters](https://igdb.github.io/api/references/filters/).
112112

113+
## Expander Example
114+
To use the expander api in structs you have to use the `expand()` function
115+
```swift
116+
var userReviews: [Review] = []
117+
118+
let params: Parameters = Parameters()
119+
.add(fields: "*")
120+
.add(expand: "game")
121+
.add(order: "created_at:desc")
122+
123+
wrapper.reviews(params: params, onSuccess: { (reveiewResponse: [Review]) -> (Void) in
124+
self.userReviews = reveiewResponse
125+
}, onError: {(Error) -> (Void) in
126+
// Do something on error
127+
})
128+
129+
let review = userReviews[1]
130+
let expandedGame = review.game?.expand() // <- Returns the expanded Struct
131+
print(expandedGame.name)
132+
133+
/* The sent request will look like this:
134+
https://api-2445582011268.apicast.io/reveiws/?fields=*&expand=game&order=created_at:desc */
135+
136+
```
137+
113138
## More examples
114139
```swift
115140

0 commit comments

Comments
 (0)