Commit 819d318b authored by Fredrik Lønnemo's avatar Fredrik Lønnemo
Browse files

it no longer crashes but it still doesnt work,

somethings wrong so the country struct doesnt get the nested json data
parent 7bab0a68
Pipeline #572 canceled with stages
......@@ -5,6 +5,8 @@ import (
"encoding/json"
"strings"
"time"
"fmt"
)
// Version states current version
......@@ -15,8 +17,16 @@ type Country struct{
Code string `json:"alpha2code"`
Countryname string `json:"name"`
CountryFlag string `json:"flag"`
Species []string `json:"results"`
SpeciesKey []string `json:"results"`
Species []Species `json:"results"`
SpeciesKey []SpeciesKey `json:"results"`
}
type SpeciesName struct{
Name string `json:"species"`
}
type SpeciesKey struct{
Key int `json:"key"`
}
// Species holds the data of a species
......@@ -75,6 +85,8 @@ func HandlerCountry(w http.ResponseWriter, r* http.Request){
client := http.DefaultClient
resp := DoRequest(client, occInput)
fmt.Print(resp.Body)
err := json.NewDecoder(resp.Body).Decode(&output)
if err != nil {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment