I am new to programming and one thing I am very confused about, my boss has told me to create a rest API about an app which I have completed all the signups, login, and other parts. But now I have to create a frontend but all the tutorials on the internet are about create rest API of Django to react or some other frontend framework, is their any tutorial on YouTube about connecting to a html CSS JavaScript on frontend to Rest API. thanks.
If you don't want a frontend just follow the official django tutorial to learn how to serve html/css/js from django.
From there you can either pass the data you need from your api down through the django context, or you can use fetch or something similar to grab it from javascript.
The latter would look like this.
# views.py
def index(request):
return render(request, 'index.html')
def apiview(request):
return JsonResponse({'title', 'served from api'})
index.html
<div class="title" token={{csrf_token}}></div>
<script>
function getTitle() {
const div = document.querySelector('title')
const csrf_token = div.getAttribute('token')
fetch('localhost:8000/apiview', {
method: 'get',
headers: {'X-CSRFToken': token}
})
.then(data => data.json())
.then(data => div.innerHTML = data.title)
}
</script>