Skip to content

Commit dd8929a

Browse files
removing hardcoded baseURL (#194)
1 parent f75ccce commit dd8929a

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

flags/pokemonflagset.go

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,7 @@ func AbilitiesFlag(w io.Writer, endpoint string, pokemonName string) error {
135135
}
136136

137137
func DefenseFlag(w io.Writer, endpoint string, pokemonName string) error {
138-
baseURL := "https://pokeapi.co/api/v2/"
139-
pokemonStruct, _, _ := connections.PokemonApiCall(endpoint, pokemonName, baseURL)
138+
pokemonStruct, _, _ := connections.PokemonApiCall(endpoint, pokemonName, connections.APIURL)
140139

141140
// Print the header from header func
142141
_, err := fmt.Fprintln(w, header("Type Defenses"))
@@ -150,7 +149,7 @@ func DefenseFlag(w io.Writer, endpoint string, pokemonName string) error {
150149

151150
typeData := make(map[string]structs.TypesJSONStruct)
152151
for _, pokeType := range pokemonStruct.Types {
153-
typeStruct, _, _ := connections.TypesApiCall("type", pokeType.Type.Name, baseURL)
152+
typeStruct, _, _ := connections.TypesApiCall("type", pokeType.Type.Name, connections.APIURL)
154153
typeData[pokeType.Type.Name] = typeStruct
155154
}
156155

@@ -320,8 +319,7 @@ func DefenseFlag(w io.Writer, endpoint string, pokemonName string) error {
320319
}
321320

322321
func ImageFlag(w io.Writer, endpoint string, pokemonName string, size string) error {
323-
baseURL := "https://pokeapi.co/api/v2/"
324-
pokemonStruct, _, _ := connections.PokemonApiCall(endpoint, pokemonName, baseURL)
322+
pokemonStruct, _, _ := connections.PokemonApiCall(endpoint, pokemonName, connections.APIURL)
325323

326324
// Print the header from header func
327325
_, err := fmt.Fprintln(w, header("Image"))
@@ -410,8 +408,7 @@ func ImageFlag(w io.Writer, endpoint string, pokemonName string, size string) er
410408
}
411409

412410
func MovesFlag(w io.Writer, endpoint string, pokemonName string) error {
413-
baseURL := "https://pokeapi.co/api/v2/"
414-
pokemonStruct, _, _ := connections.PokemonApiCall(endpoint, pokemonName, baseURL)
411+
pokemonStruct, _, _ := connections.PokemonApiCall(endpoint, pokemonName, connections.APIURL)
415412

416413
_, err := fmt.Fprintln(w, header("Learnable Moves"))
417414
if err != nil {
@@ -446,7 +443,7 @@ func MovesFlag(w io.Writer, endpoint string, pokemonName string) error {
446443
go func(moveName string, level int) {
447444
defer wg.Done()
448445

449-
moveStruct, _, err := connections.MoveApiCall("move", moveName, baseURL)
446+
moveStruct, _, err := connections.MoveApiCall("move", moveName, connections.APIURL)
450447
if err != nil {
451448
errorsChan <- fmt.Errorf("error fetching move %s: %v", moveName, err)
452449
return
@@ -556,8 +553,7 @@ func MovesFlag(w io.Writer, endpoint string, pokemonName string) error {
556553
}
557554

558555
func StatsFlag(w io.Writer, endpoint string, pokemonName string) error {
559-
baseURL := "https://pokeapi.co/api/v2/"
560-
pokemonStruct, _, _ := connections.PokemonApiCall(endpoint, pokemonName, baseURL)
556+
pokemonStruct, _, _ := connections.PokemonApiCall(endpoint, pokemonName, connections.APIURL)
561557

562558
// Print the header from header func
563559
_, err := fmt.Fprintln(w, header("Base Stats"))
@@ -652,8 +648,7 @@ func StatsFlag(w io.Writer, endpoint string, pokemonName string) error {
652648
}
653649

654650
func TypesFlag(w io.Writer, endpoint string, pokemonName string) error {
655-
baseURL := "https://pokeapi.co/api/v2/"
656-
pokemonStruct, _, _ := connections.PokemonApiCall(endpoint, pokemonName, baseURL)
651+
pokemonStruct, _, _ := connections.PokemonApiCall(endpoint, pokemonName, connections.APIURL)
657652

658653
// Print the header from header func
659654
_, err := fmt.Fprintln(w, header("Typing"))

0 commit comments

Comments
 (0)