anto
This commit is contained in:
@@ -74,25 +74,42 @@ async function getDataVideoFromApi(id) {
|
||||
|
||||
async function postNewVideo(project_id, measurements_id, name_video, resolution, duration) {
|
||||
try {
|
||||
const measures = JSON.stringify(measurements_id);
|
||||
const mydata = JSON.stringify({
|
||||
project_id: project_id,
|
||||
measurement_ids: measures, // Ensure this matches the expected field name
|
||||
name: name_video,
|
||||
resolution: resolution,
|
||||
duration: duration
|
||||
});
|
||||
console.log(mydata);
|
||||
|
||||
const response = await $.ajax({
|
||||
url: api_url.concat(`/videos/`),
|
||||
method: "POST",
|
||||
dataType: "json",
|
||||
contentType: "application/json", // Specify the content type as JSON
|
||||
data: JSON.stringify({
|
||||
project_id: project_id,
|
||||
measurements_id: measurements_id,
|
||||
name_video: name_video,
|
||||
resolution: resolution,
|
||||
duration: duration
|
||||
})
|
||||
contentType: "application/json",
|
||||
data: mydata
|
||||
});
|
||||
// If the request is successful, store the data in the cache and return it
|
||||
|
||||
console.log("Video posted successfully:", response);
|
||||
return response;
|
||||
} catch (error) {
|
||||
console.error("Error posting video:", error);
|
||||
throw error; // Re-throw the error to handle it outside the function if needed
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async function getVideoFromApi(id) {
|
||||
try {
|
||||
const response = await $.ajax({
|
||||
url: api_url.concat(`/videos/${id}`),
|
||||
method: "GET",
|
||||
dataType: "json",
|
||||
});
|
||||
// If the request is successful, store the data in the cache and return it
|
||||
return response;
|
||||
} catch (error) {
|
||||
console.error("Error fetching data:", error);
|
||||
throw error; // Re-throw the error to handle it outside the function if needed
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user