Итак, у меня есть список массива movie = list, который я хотел узнать, как я могу использовать запросы Http в манипуляциях с DOM и отображать их в пользовательском интерфейсе.
Выше список в консолии ниже мой код для запросов http
const settings = {
"async": true,
"crossDomain": true,
"url": "http://localhost:3000/movielist",
"method": "GET",
"headers": {
"content-type": "application/json",
"cache-control": "no-cache",
"postman-token": "4b2ceae7-dcc8-ad44-0089-9ebf43025dff"
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
const settings2 = {
"async": true,
"crossDomain": true,
"url": "http://localhost:3000/movielist/addMovie",
"method": "POST",
"headers": {
"content-type": "application/json",
"cache-control": "no-cache",
"postman-token": "b3aea0fe-3e2f-43d6-e5f6-80bfce7492fb"
},
"processData": false,
"data": " {\n \"idmovielist\": 7,\n \"name\": \"The king is cool\",\n \"thumnail_path\": \"youtube.com.jpg\",\n\"description\": \"action\",\n \"year_released\": \"2014\",\n \"language_released\": \"hindi\"\n }"
}
$.ajax(settings2).done(function (response) {
console.log(response);
});
const setting3 = {
"async": true,
"crossDomain":true,
"url":"http://localhost:3000/movielist/4",
"method": "DELETE",
"headers": {
"content-type":"appliction/json",
"cache-control":"no-cache",
"post-token":"dc8577f1-af8c-c004-1def-3b1e9a5fb802"
},
"processData": false,
"data": " {\n \"idmovielist\": 4,\n \"name\": \"Chennai Express\",\n \"thumnail_path\": \"amazon.com.jpg\",\n \"description\": \"comedy\",\n \"year_released\": \"2013\",\n \"language_released\": \"hindi\"\n }"
}
$.ajax(setting).done(function (response) {
console.log(response);
});
const settings4 = {
"async": true,
"crossDomain": true,
"url": "http://localhost:3000/movielist/update/1",
"method": "PUT",
"headers": {
"content-type": "application/json",
"cache-control": "no-cache",
"postman-token": "1c2cb298-bfaa-152d-c6e0-165d020755a8"
},
"processData": false,
"data": "{\n \"idmovielist\": 1,\n \"name\": \"The Angreez 2\",\n \"thumnail_path\": \"https://i.ytimg.com/vi/iInthnfhbt.jpg\",\n \"description\": \"comedy\",\n \"year_released\": \"2016\",\n \"language_released\": \"telgu\"\n }"
};
$.ajax(settings4).done(function (response) {
console.log(response);
});
Этот код выше показывает все запросы, которые я сделал для внешнего интерфейса, чтобы показать в консоли.