Сюда приходит get запрос. В ответ получает json
def loadArticles(request):
count = request.GET.get('count', 5)
count = int(count)
latest_articles_list = Article.objects.order_by('-pub_date')[count:count+5]
response_data = []
article = {}
for a in latest_articles_list:
article["img"] = a.article_image.name
article["title"] = a.article_title
article["text"] = a.article_text
article["date"] = a.pub_date
response_data.append(article)
context = json.dumps(response_data, indent=4, sort_keys=True, default=str)
return HttpResponse(context, content_type="application/json")
Потом запрос принимается и по идеи json должен распарситься и в консоле я должен получить массив со статьями, но я получаю undefined
fetch(`/loadArticles?count=${articlesLoaded}`, {method: "GET"})
.then(res => {res.json()})
.then(article => {
console.log(article)
})
.catch(e => {console.log(e)})
Вот, что получается в консоли