在Mangaeden API Angular 6中无法获取图像URL [英] Unable to get image url in Mangaeden API Angular 6

查看:93
本文介绍了在Mangaeden API Angular 6中无法获取图像URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试获取Mangaeden API的信息,并且成功获得了响应,但是当我从url渲染图像时.我收到了错误403.似乎在API中进行请求时遇到了问题.

I have tried to get the information of the Mangaeden API and I have successfully get a response but when I rendered the image from the url. I got an error 403. It seems there is a problem in requesting in the API.

这是应用程序中的错误.

This is the error in the application.

获取 https://cdn.mangaeden.com/mangasimg/63/63df51e43ebfb2394327392b37943e2ebf3e3eb3617b2e3e3eb3e2e3eb3e3e3eb3e2e3eb2e3b3e2e3b3b3e0b0e0b0e3b0b0b0b人>403

GET https://cdn.mangaeden.com/mangasimg/63/63df51e43ebfb8983eb39744496b27ef6173b2237535b9c2408ea32d.jpg 403

但是当我尝试在浏览器中加载该URL并下次在我的应用程序中尝试该URL时,它起作用了,因为我认为它将在浏览器中缓存该图像.

But when I tried to load the url in the browser and the next time I try it on my application, It works because I think it will cache the image in the browser.

这是Mangaeden API信息

This is the Mangaeden API Information

您可以通过以下方式获取所有漫画信息,章节和mymangamangaeden的API.所有信息均以JSON格式发送.你可以使用HTTP或HTTPS(建议使用mymanga的API).重要提示:我们要求每个API用户都有指向我们网站的链接在他们的应用程序/站点中.新功能:我们现在也支持CORS

You can get all manga informations, chapters and mymanga with mangaeden's API. All the informations are sent in JSON format. You can either use HTTP or HTTPS (advised if you need to use the mymanga's API). Important: we require every API user to have a link to our site in their application/site. New: We also support CORS now

关于此.我在哪里可以添加他们的链接

About this. Where can I add their link

我们要求每个API用户在其网站上都具有指向我们网站的链接应用程序/站点.

We require every API user to have a link to our site in their application/site.

HTML

<img src="{{url}}">

组件代码

@Component({
  selector: 'app-list',
  templateUrl: './list.component.html',
})
export class ListComponent implements OnInit {
  url: String;

  constructor(private mangaedenService: MangaedenService) {}

  isRedered(id) {
    this.url = null;

    this.mangaedenService.getInfo(id)
      .subscribe(data => {
        this.url = 'https://cdn.mangaeden.com/mangasimg/' + data.image;
      });
  }
}

服务代码

import { Injectable } from '@angular/core';
import 'rxjs/add/operator/map';
import { HttpClient } from '@angular/common/http';

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

  constructor(private http: HttpClient) {}

  getInfo(id) {
    return this.http.get('https://www.mangaeden.com/api/manga/' + id)
      .map(this.extract);
  }

  private extract(res: Response | any) {
    return res || {};
  }
}

推荐答案

实际上,我的代码没有问题.在html中渲染图像时出现错误,得到403响应.我在html代码中添加了它,并且可以正常工作.

Actually, there is no problem in my code. I got error when rendering images in html which got 403 response. I added this in my html code and It works.

<元名称="referrer" content ="no-referrer"/>

您也可以查看

删除http推荐人

这篇关于在Mangaeden API Angular 6中无法获取图像URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆