Django Rest Framework: Creating API(s)

I am facing issues with the below problem, I am unable to develop a logic to get info from an external URL. As the problem states.

1.Create a basic HTML page which with a dropdown box. Please use simple Python Django web framework.The form has two values: Product and Expiry. Dropdown should have values perfume, bodyspray and scents . Below that, create a submit button.

2.When Submit button is clicked it should call an Rest api mentioned below. Value selected from the DropDown should be passed in the Request Body.

Rest Api URL = can not reveal.

Method: POST

Request Body Json:

{
   "product":"perfume"
}
  1. When you call this Rest Api, you will get the product related data for perfume.

Please help me to get out of this problem, what should I do in order to get info from an external URL.

I think you should try with ajax:

var data = {"product":"perfume"}
$.ajax({
           type: 'POST',
           data: data,
           url: 'your API URL',
           success: function(res){
                   console.log(res)  //answer of api call.
                   });
           },
           error: function(error) {
               callbackErr(error,self)
           }
       })
Back to Top