Method not allowed DRF 405

I have API that should retrieve data about some country based on their names. But instead I'm getting error Method not allowed. How do I fix it? I am not using models for the countries.

def get_country_info(country):
    country_info = {
        "Germany": [
            _("Germany is a country with a rich history and culture, located in Central Europe. It is home to world-famous cities such as Berlin, Munich, Hamburg and Cologne. Germany is famous for its architecture, museums, beer and sausages."),
            ['img1', 'img2'],
        ],
        "USA": _(
            "The USA is the largest country in the world by area and population. It is located in North America and is a leading global economic and cultural center. The USA is known for its skyscrapers, Hollywood, Disneyland and Niagara Falls."
        ),
        "UK": _(
            "The United Kingdom is an island nation located in the North Atlantic. It comprises England, Scotland, Wales and Northern Ireland. The UK is the birthplace of the English language, Parliament, Big Ben and Queen Elizabeth II."
        ),
        "Turkey": _(
            "Turkey is a country located at the crossroads of Europe and Asia. It is known for its beaches, ancient ruins, mosques and bazaars. Turkey is a popular tourist destination for lovers of history, culture and beach holidays."
        ),
        "France": _(
            "France is a country located in Western Europe. It is the home of the Eiffel Tower, the Louvre, croissants and frog legs. France is known for its exquisite cuisine, fashion and art."
        ),
        "Italy": _(
            "Italy is a country located in Southern Europe. It is the home of the Colosseum, the Roman Forum, the Leaning Tower of Pisa and pizza. Italy is famous for its history, culture and cuisine."
        ),
        "Russia": _(
            "Russia is the largest country in the world by area. It is located in Eurasia and includes a multitude of natural and cultural attractions. Russia is known for its history, culture, ballet and vodka."
        ),
        "Belarus": _(
            "Belarus is a country located in Eastern Europe. It is the home of Minsk, the Belovezhskaya Pushcha and the Nesvizh Castle. Belarus is known for its rich history and culture."
        ),
        "Uzbekistan": _(
            "Uzbekistan is a country located in Central Asia. It is the home of Samarkand, Bukhara and Khiva. Uzbekistan is known for its rich history and culture."
        ),
        "Kazakhstan": _(
            "Kazakhstan is a country located in Central Asia. It is the home of Almaty, Lake Baikal and the Baikonur Cosmodrome. Kazakhstan is known for its rich nature and history."
        ),
        "Armenia": _(
            "Armenia is a country located in the Middle East. It is the home of Yerevan, Mount Ararat and Armenian brandy. Armenia is known for its rich history and culture."
        ),
        "Azerbaijan": _(
            "Azerbaijan is a country located in the Caucasus. It is the home of Baku, Ganja and the Azerbaijani carpet. Azerbaijan is known for its rich history and culture."
        ),
        "India": _(
            "India is a country located in South Asia. It is the home of Delhi, the Taj Mahal and yoga. India is known for its rich history, culture and cuisine."
        ),
        "Thailand": _(
            "Thailand is a country located in Southeast Asia. It is the home of Bangkok, Phuket and Thai massage. Thailand is known for its rich culture, nature and cuisine."
        ),
        "Japan": _(
            "Japan is a country located in East Asia. It is the home of Tokyo, Kyoto and sushi. Japan is known for its modern culture, technology and cuisine."
        ),
        "South-Korea": _(
            "South Korea is a country located in East Asia. It is the home of Seoul, Busan and Korean pop music. South Korea is known for its modern culture, technology and cuisine."
        ),
        "China": _(
            "China is a country located in East Asia. It is the home of Beijing, the Great Wall of China and Chinese cuisine. China is known for its rich history, culture and economy."
        ),
    }
    return country_info.get(country, None)

my DRF code:

@api_view(["POST"])
def get_country_data(request, pk = None):
    country_name = request.data.get("id")
    print(country_name)
    return Response({country_name : get_country_info(country_name)})

urls.py:

urlpatterns = [
    path("api/", views.get_country_data)
]

js:

const country_icons = document.querySelectorAll(".country-icon");
country_icons.forEach((icon)=>{
  
  icon.addEventListener("click", (e)=>{
    let id = e.target.id
    fetch(`/countries-api/api/`,{
      method: "POST",
      body: JSON.stringify({
        id : id
      }),
      headers:{"X-CSRFToken": getCookie('csrftoken') }
    })
    .then(response => response.json())
    .then(data => {
      let text = data[e.target.id]
      let modal_body = document.querySelector("#modal-body");
      modal_body.innerHTML = text

      })
  })

})
Back to Top