Z
Z
zlodiak2021-06-24 01:39:56
Angular
zlodiak, 2021-06-24 01:39:56

How to download bpmn file?

I get a bpmn file via http. Through the network tab, I see that this file is coming to the browser. It's in XML format. The problem is that when trying to display the contents of the response via console.log()

this.service.getBpnm(123).subscribe(bpnm => {
  debugger
  console.log(bpnm);
});


I am getting the following error message:

error:
error: SyntaxError: Unexpected token < in JSON at position 0 at JSON.parse ...
headers: HttpHeaders {normalizedNames: Map(0), lazyUpdate: null, lazyInit: ƒ}
message: "Http failure during parsing for http://localhost:4200/..."
name: "HttpErrorResponse"
ok: false
status: 200
statusText: "OK"
url: "http://localhost:4200/...


At the same time, I specified the MIME type in the request:
return this.http.get('qwerty', { headers: new HttpHeaders().set('Content-Type', 'application/octet-stream') });


I also tried to specify "application/xml" instead of "application / octet-stream"

Please tell me how to display the contents of the response through console.log ()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
acwartz, 2021-06-24
@acwartz

In addition to headers, specify a responseType other than json.

options: {
    headers?: HttpHeaders | {[header: string]: string | string[]},
    observe?: 'body' | 'events' | 'response',
    params?: HttpParams|{[param: string]: string | number | boolean | ReadonlyArray<string | number | boolean>},
    reportProgress?: boolean,
    responseType?: 'arraybuffer'|'blob'|'json'|'text',
    withCredentials?: boolean,
  }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question