IEnumerator GetJoinedEventsInfoFromServer() { Debug.Log("joined events"); UnityWebRequest www = UnityWebRequest.Get("https://echoes.etc.cmu.edu/api/viewer/events/joined"); www.SetRequestHeader("Authorization", "Bearer " + PlayerPrefs.GetString("token")); //"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiI0NjQ4NjkzNTciLCJ0b2tlbiI6eyJhY2Nlc3NfdG9rZW4iOiJ1MW94OHZnNjdrMHR4bHJ1bGdqOGJzeWdpOXFxbG0iLCJyZWZyZXNoX3Rva2VuIjoiNGR6ejZhYXo5bHR2anNpOGJ3ZGdmMnA5bXE0cHA5aml0eWVqbjIwMXZhNGV4eHI0dGEifSwiaWF0IjoxNTc0Mzk5MjA3LCJleHAiOjE2MDU5NTY4MDd9.QkD55bcWmD-qcszgMssVKydhzGFs169KUzFih9d14Hg"); yield return(www.SendWebRequest()); if (www.isNetworkError || www.isHttpError) { Debug.Log(www.error + " : " + www.downloadHandler.text); } else { var data = www.downloadHandler.text; joinedEvents = JsonClassEvents.getEventsInfo(data); int total = 0; if (joinedEvents.Count == 0) { numberOfJoinedEvents.Value = 0; } else { for (int i = 0; i < joinedEvents[3].Count; i++) { if (System.DateTime.Compare(System.DateTime.Parse(joinedEvents[3][i]), System.DateTime.Now) > 0) { total++; } } Debug.Log("joined events total : " + total); numberOfJoinedEvents.Value = total; populateJoinedEvents.StartPopulating(); } } }
IEnumerator GetEventsInfoFromServer() { UnityWebRequest www = UnityWebRequest.Get("https://echoes.etc.cmu.edu/api/viewer/events"); www.SetRequestHeader("Authorization", "Bearer " + PlayerPrefs.GetString("token")); yield return(www.SendWebRequest()); if (www.isNetworkError || www.isHttpError) { Debug.Log(www.error + " : " + www.downloadHandler.text); } else { var data = www.downloadHandler.text; events = JsonClassEvents.getEventsInfo(data); int total = 0; if (events.Count == 0) { numberOfEvents.Value = 0; } else { for (int i = 0; i < events[3].Count; i++) { if (System.DateTime.Compare(System.DateTime.Parse(events[3][i]), System.DateTime.Now) > 0) { total++; } } Debug.Log("events total : " + total); numberOfEvents.Value = total; populateEvents.StartPopulating(); } } }