cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Using Fetch with an ASP.NET Core app

In a bid to replace jQuery in our applications at work, I'm trying to retrieve data and place it into HTML elements on the page. The controller code runs fine and will return a json string ouputted to the browser if I manually go to the URL.

If I use Ajax and $.get, it works fine.

If I use fetch however, the most I seem to be able to get back is the header. I can't output any data to the console or utilise the data in my elements.

I'm using .NET Core 3.1 with System.Text.Json, rather than Newtonsoft.

Example code I use and taken directly from MDN:

fetch('/Controller/Action/Id') .then((response) => { return response.json(); }) .then((data) => { console.log(data); });

 

 

BrandonKai
Member
0 REPLIES 0