I have created an API in Django where you type a variable in the URL and it makes a JSON response.
For example, we have this URL:
And the JSON response is:
{"id": 1, "string": "iamnewtojavascript"}
How to return this JSON in JavaScript. I have searched the web but none of the results gave me a satisfying answer.
In Python the code is this simple:
import requests
import json
url = "http://127.0.0.1:8000/api/string/IAMNEWTOJAVASCRIPT"
req = requests.post(url)
p = req.json()
data = json.dumps(p)
print(data)