Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

Downloading PDF/image with blob

$
0
0

Hi I'm bothering with display data in logs by console.log(). I'm using redux toolkit with react native and I'm always getting an undefined in response.So this is where I made my query:

downloadInvoice: builder.query<      { blob: string },      {        invoiceId?: string;        variant: 'original' | 'duplicate';      }>({      query: params => ({        url: `v1/company_invoices/${params.invoiceId}/download`,        method: 'GET',        params: {          variant: params.variant        }      })    }),

As you can see I only want one param in payload. It's just a very long string (blob I think), without any name before it.

In web developer tools I see this payload and status code 200.

I invoke this query like this:

[...]const [downloadInvoice, result] = useLazyDownloadInvoiceQuery();[...]<Button  title={'TestButton'}  onPress={() => {    downloadInvoice({       invoiceId: invoiceId,      variant: 'original'    }),    console.log(result?.data);    console.log(invoiceId);  }}></Button>

I've never had problems with displaying fetched data, so I don't really know where is a problem.

EDIT:The same problem occurs when I use useMutation and useQuery


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>