V
V
Vasya2021-11-12 10:35:01
API
Vasya, 2021-11-12 10:35:01

How to get a waybill by api cdek and print it out?

Tell me how to print an invoice document from cdek api?
I reach the link that comes from the sdek, like: api.cdek.ru/v2/print/orders/72753034-4b28-40af-a89...
If I make a request via postman, the file appears in the response window, but how to get it I don’t understand through axios and open it in my application for printing.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasya, 2021-11-17
@wordpost

The config needs to be corrected and a reference to the object should be returned

const config: HttpClientConfig = {
    responseType: 'arraybuffer',
    transformResponse(data: any, headers?: any) {
      const objectUrl = new Blob([data], { type:"application/pdf; charset-UTF-8" })
      const blobUrl = URL.createObjectURL(objectUrl)
      setTimeout(() => {
        URL.revokeObjectURL(blobUrl)
      }, 2000)
      return blobUrl
    },
  }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question