-3

I have to create a widget in pure javascript, html and css for an application existing.

I looked on the internet for tutorials but I couldn't find anything.

My problem: I would like to connect to the database/API knowing that the application is coded in Django/Angular 8.

Yes indeed I will use fetch to retrieve my data. Here is my code:

const url = 'http://localhost:8000/api/services';

fetch(url)
    .then(res => {
        res.json()
    })
    .then(data => {
        console.log(JSON.stringify(data))
    });

I think i have found what i want here

But i don't understand this line:

{% load static %}
<script src="{% static 'rest_framework/js/coreapi-0.1.1.js' %}"></script>
<script src="{% url 'api-docs:schema-js' %}"></script>

My widget is encoded outside my django application, so i can't use '{% %}'.

Thanks

Ailleurs
  • 31
  • 1
  • 6

1 Answers1

-1

By connect, do you mean communicate with a rest api? If so then you should be ale to use window.fetch

The linked MDN article provides examples on how you would be able to do this.

Nnanyielugo
  • 401
  • 4
  • 13