Skip to content

Commit 5580245

Browse files
committed
[Twitch] Subscriber Emotes - When requesting JSON, missing keys would return a JSON object, not array
1 parent deec5d4 commit 5580245

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

app/Http/Controllers/TwitchController.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1957,12 +1957,17 @@ public function subEmotes(Request $request, $channel = null)
19571957

19581958
/**
19591959
* At this point we only want the emote codes.
1960+
*
1961+
* `array_values` is used because it seems that sometimes it returns an array with missing keys.
1962+
* When JSON-encoding it, it turns it into an object.
19601963
*/
1961-
$emoteCodes = array_map(
1962-
function($emote) {
1963-
return $emote['code'];
1964-
},
1965-
$emotes
1964+
$emoteCodes = array_values(
1965+
array_map(
1966+
function($emote) {
1967+
return $emote['code'];
1968+
},
1969+
$emotes
1970+
)
19661971
);
19671972

19681973
if ($wantsJson) {

0 commit comments

Comments
 (0)