Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular从RESTAPI上不断获取图片并显示它_Angular_Image_Get_Insomnia - Fatal编程技术网

Angular从RESTAPI上不断获取图片并显示它

Angular从RESTAPI上不断获取图片并显示它,angular,image,get,insomnia,Angular,Image,Get,Insomnia,我要创建一个网站,它将在计算机屏幕上实时显示驾驶汽车拍摄的图像。 我正在通过以下方式发送图片(我还没有服务器): 还有一个来自Angular的代码: 视频流.service.ts import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; @Injectable({ providedIn:

我要创建一个网站,它将在计算机屏幕上实时显示驾驶汽车拍摄的图像。 我正在通过以下方式发送图片(我还没有服务器):

还有一个来自Angular的代码:

视频流.service.ts

import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';

@Injectable({
  providedIn: 'root'
})
export class VideoStreamingService {

  constructor(private http: HttpClient) { }

  getFiles(url: string): Observable<any> {
    return this.http.get(url); // 'http://localhost:8080/api/file/all' anykind
  }
}
import { Component, OnInit } from '@angular/core';
import { VideoStreamingService } from './video-streaming.service';


@Component({
  selector: 'app-video-streaming',
  templateUrl: './video-streaming.component.html',
  styleUrls: ['./video-streaming.component.css']
})
export class VideoStreamingComponent implements OnInit {

  image: any;
  constructor(private videoStreamingService: VideoStreamingService) { }

  ngOnInit() {
    this.getImage('https://192.168.0.102:8080/image');
  }

  getImage(url: string): void {
    this.videoStreamingService.getFiles(url)
      .subscribe(image => {
        this.image = image;
      });
  }
}
以及HTML模板

<img src={{image}}>
我做错了什么

@更新

我确实换了线路

this.getImage('https://192.168.0.102:8080/image');
为此:

this.getImage('http://localhost:8080/image');
此外,还应提供以下地址:

有更多错误,详情如下

控制台中的角度误差:

失眠错误:


您收到一个超时错误,因为在网络中找不到提供的api url,搜索该url时已超时

此IP地址是wifi路由器提供的动态IP地址的一部分

如果从本地计算机访问映像,请使用此地址

http://localhost:8080
不要在http上使用https


https是指域是安全的。

后端控制台上是否有任何错误?或者详细的http错误消息是什么?你不需要CORS实现吗?我只使用失眠,我不能实现CORS。查看顶部我的帖子的@update。非常感谢。是否有任何服务监听localhost:8080?您在chrome控制台>网络选项卡中看到了什么?当你在浏览器中的单独选项卡中转到url:时,你会看到什么?我不知道如何添加带有大描述的注释,因此我将编辑问题页面
http://localhost:8080