Skip to content

Call Api from javascript #1

@mtugnoli

Description

@mtugnoli

Is it possible to call WeatherForecast Api by javascript from Ajax ?
how is the token used ?

I try this, but seem not run..

$.ajax({
type: 'GET',
url: "http://localhost:4321/WeatherForecast",
contentType: "application/json; charset=utf-8",
dataType: "JSON",
beforeSend: function (xhr) {
xhr.setRequestHeader('ApiKey', 'hL4bA4nB4yI0vI0fC8fH7eT6');
},
success: function (result) {
alert(JSON.stringify(result));

},
error: function (xhr, status, error) {
	alert(error);
}

});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions