Problem with Angular 4 HttpClient


This api along with the parameters is working if I use Postman, but as I’m new into Angular 4 and when I try to write the code matching postman configuration it simply doesn’t work. Can you please look at my code and let me know my mistake.
Here’s my code.

What error you are getting?

1 Like

People are more likely to help if you post text instead of pictures for your code

1 Like

i get the following error.

Here’s the code.

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

export class PdfServiceProvider
  private url:string;

  constructor(public http:HttpClient)

  public fetch():void
    this.url = "";

    let body:any = {
      orientation: "portrait",
      paperSize  : "letter",
      htmlContent: `<h1>Hello</h1>`,
      return_url : "true",
    };, body).
         subscribe(res => console.log(res));

As an aside you know you can generate PDF’s locally right?

There’s another is library called pdfmake which is supposed to be even better, not had chance to check it out.

Otherwise I’ll have a play this wknd

I’ve just checked it pdfmake out. Omg it’s WAY better.

Forget whatever you’re doing and do that instead!!! Fully offline, no Cors issues, beautiful structure.

I’ve checked pdfmake & jspdf but both are printing text as a pdf file. I want to make pdf from my html content. How can i pass my html content to pdfMake?

You’d need to change your strategy. Pass what it’s expecting, it’ll yield the most professional looking result.