ksiegowybk
ksiegowybk

Reputation: 39

Get Data From external API with Blazor WASM

I try to get data from external API with blazor WASM but i've got exception: "TypeError: NetworkError when attempting to fetch resource" My code is like belowe. Coulde someone tell me what should i do to get this data? Thank you in advance.

    public class Rate
        {
        public string no { get; set; }
        public string effectiveDate { get; set; }
        public double mid { get; set; }
        }

    public class Nbp
        {
        public string table { get; set; }
        public string currency { get; set; }
        public string code { get; set; }
        public Rate[] rates { get; set; }
        }
//...
var test = await Http.GetFromJsonAsync<Nbp>("http://api.nbp.pl/api/exchangerates/rates/A/EUR/2020-12-15/?format=json");

Upvotes: 1

Views: 841

Answers (1)

Brian Parker
Brian Parker

Reputation: 14573

Change your request to https.

var test = await Http.GetFromJsonAsync<Nbp>("https://api.nbp.pl/api/exchangerates/rates/A/EUR/2020-12-15/?format=json");

Upvotes: 1

Related Questions