12345678910111213141516171819202122232425262728293031323334353637383940 |
- import axios from "axios";
- export async function get_video_url(item) {
- try {
- const tokenResponse = await axios({
- method: 'post',
- url: 'http://anvideo.nxmy.com:8011/api/oauth/token',
- headers: {
- 'Content-Type': 'multipart/form-data'
- },
- data: {
- username: 'admin',
- password: 'Zhks123456+'
- }
- });
- const token = `${tokenResponse.data.data.token_type} ${tokenResponse.data.data.access_token}`;
- const videoUrlResponse = await axios({
- method: 'post',
- url: 'http://anvideo.nxmy.com:8011/api/camera/geturl',
- headers: {
- Authorization: token
- },
- data: {
- camera_id: item.camera_id,
- parent_id: item.parent_id
- }
- });
- if (videoUrlResponse.data.content.data.url) {
- return videoUrlResponse.data.content.data.url;
- } else {
- throw new Error('No URL found in response');
- }
- } catch (error) {
- console.error(error);
- throw error; // Re-throw the error to be handled by the caller
- }
- }
|