Ax ios get params массив преобразует в строку - PullRequest
0 голосов
/ 24 января 2020

Ax ios

    var datas=[{"ticket_no": "1","details": "detail1"}];
    instance.get(`somepath`, {
        params: ({
            data:datas,
        }),
        responseType: 'blob',Accept: 'application/pdf',
        }).then((response) => {
            const file = new Blob(
                [response.data], 
                {type: 'application/pdf'});
            const fileURL = URL.createObjectURL(file);
            //Open the URL on new Window
            window.open(fileURL);

        }).catch((error) => {
            console.log(error)
        }).finally(() => {
        })

PDF.test

{{data}}

// возвращает "{ticket_no: 1, details: detail1}" // не массив, а строка

1 Ответ

0 голосов
/ 24 января 2020

var datas = [{"ticket_no": "1", "details": "detail1"}]; instance.get (somepath, {params: ({data: JSON .stringify (datas),}), responseType: 'blob', Accept: 'application / pdf',}). then ((response) = > {const file = new Blob ([response.data], {type: 'application / pdf'}); const fileURL = URL.createObjectURL (file); // Открыть URL-адрес в новом окне window.open (fileURL);

    }).catch((error) => {
        console.log(error)
    }).finally(() => {
    })

// Контроллер

    $pdf = PDF::loadView('PDF.pdf_irregularity',['data' => json_decode($request->data)])->setPaper('A5', 'landscape');
    $fileName = 'Irregulairty';
    return $pdf->output();
...