title: Using Fetch with Javascript and Django
body: <p>I am new to Javascript and I am using Django.</p>
  <p>I've read documentation about the Javascript fetch API but I'm confused about something - if anyone can explain it I'd really appreciate it.</p>
  <p>I've seen code that didn't include a url for the API. Where is this coming from within the framework - when I write code, how do I know what to put right after the fetch part?</p>
  <p>Example:</p>
  <pre><code>const load_like = (post, postLikes, likePost, current_user) =&gt; {
      const csrftoken = getCookie('csrftoken');
      fetch(`/post/${post.id}`, {
          method: 'PUT',
          body: JSON.stringify({
              likes: [post.original_poster.id]
          }),
          headers: { &quot;X-CSRFToken&quot;: csrftoken }
      })
          .then(response =&gt; response.json())
          .then(data =&gt; {
              display_likes(data, postLikes, likePost, current_user)
          })
  }
  </code></pre>
  <p>Is this done in urls.py ?
  For example would it be:</p>
  <pre><code> path(&quot;post/&lt;int:post_id&gt;&quot;, views.post, name=&quot;post&quot; ),
  </code></pre>
  <p>I want to make sure I understand how to write this type of line and understand why these parts should go here:</p>
  <pre><code>fetch(`/post/${post.id}
  </code></pre>