I’m trying to use spine in pixi.js project but it comes with unexpected problem

Hello I’m trying to use Spine for my small pixi.js application.

So the main problem here in my project is that, whenever I’m trying to initialize spine in some file it only gives me one error enter image description here

I’m also sharing these chunks of codes that I’m using for example: loading assets,calling spine and etc.

ALSO VERSIONS THAT I’M USING
Pixi.js v7.3.2 | pixi-spine v4.0.4 | And exported spine is “spine”: “3.8.75” version

This is method to get spine:

getSpine(key: string, bundle: string = BundlesEnum.GAME_ICONS): any {
    return this.loaded[bundle][key];
  }

Class where I’m trying to call this loaded Spine:

import { Container } from "pixi.js";
import { RESOURCES } from "../global/global.config";
import { Spine } from "pixi-spine";

export default class SpineView extends Container {
  constructor() {
    super();

    this.draw();
  }

  draw() {
    // This takes spineBoy resource from loaded resources
    const resource = RESOURCES.getSpine("spineboy");
    console.log(resource);

    // and here it is getting assigned to Spine
    const spine = new Spine(resource);
    this.addChild(spine);

    // This should work right? NO IT DOESNT
  }
}

And also here is the method which I’m using for loading resources (btw this method works)

private async loadAssets(bundles: string[] = []): Promise<void> {
    const manifest = this.unloadedResources;

    const bundlesToLoad =
      bundles.length == 0
        ? manifest.bundles?.map((bundle: any) => bundle.name)
        : bundles;

    await Assets.init({ manifest });

    return Assets.loadBundle(bundlesToLoad);
  }

I’ve checked everything and as I can see it logs out this object which is spineData as I can seeenter image description here

I checked everything naming loading assets and etc, everything but nothing gives me proper answer of what might be the problem, even the almighty chatgpt can’t help me.

It logs out error which i mentioned in top bar… so anyone who knows something about this please help if u need any more info just tell me and I can add to it.

Thank you in advance!

Slick Slider with youtube videos not showing first one

I have a page with a slick slider that each slide has a iframe of a youtube embed video. For some reason the first video doesn’t show up. If I change the video to another location it shows and if I change to a video that works on another slider, it stops working if it’s in the first position.
Could you help me figure it out?

PHP Loop

            <div class="slider-card-carrossel-off">
                <video controls>
                    <source src="<?php echo $video_link_carrossel_off; ?>" type="video/mp4">
                </video>
            </div>
        <?php endif; ?>

Javascript

```<script>
    jQuery(function(){
        jQuery('.slider-carrossel-off').slick({
            slidesToShow: 1,
            arrows: true,
            dots: false,
            centerMode: true,
            centerPadding: '300px',
            nextArrow: '<button type="button" class="slick-next"><i class="ge-setadireita"></i></button>',
            prevArrow: '<button type="button" class="slick-prev"><i class="ge-setaesquerda"></i></button>',
            responsive: [
                {
                breakpoint: 1399,
                settings: {
                    centerPadding: '200px',
                }
                },
                {
                breakpoint: 991,
                settings: {
                    centerPadding: '100px',
                }
                },
                {
                breakpoint: 767,
                settings: {
                    centerPadding: '50px',
                }
                }
            ]
        });
    });
    </script>
ass

How to load WooCommerce checkout form into a Bootstrap modal via AJAX in WordPress?

I’m building a one-page WordPress site using WooCommerce for e-commerce functionality. I have a shopping cart that opens in a Bootstrap modal. When a user clicks “Proceed to Checkout,” I want to load the WooCommerce checkout form into the same modal via AJAX, instead of redirecting to a separate checkout page.

What I’ve Done:

1. Shopping Cart Template (shopping-bag.php):

<div class="modal-header">
    <h4 class="modal-title" id="cartModalLabel">Shopping Cart</h4>
    <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body">
    <div id="cartContent">
        <?php foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
            $_product   = $cart_item['data'];
            // Display cart items
        } ?>
    </div>
    <div id="checkoutContent" style="display: none;">
        <!-- Checkout form will be loaded here -->
    </div>
</div>
<div class="modal-footer">
    <button type="button" class="btn btn-light" data-bs-dismiss="modal">Close</button>
    <button type="button" id="proceedToCheckoutButton" class="btn btn-primary" onclick="proceedToCheckout()">Proceed to Checkout</button>
    <button type="button" id="goBackToCartButton" class="btn btn-secondary" style="display: none;" onclick="goBackToCart()">Go Back</button>
</div>

2. JavaScript Function to Load Checkout via AJAX:

function proceedToCheckout() {
    fetch(woocommerce_params.ajax_url, {
        method: 'POST',
        headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
        body: new URLSearchParams({ action: 'load_checkout_form' })
    })
    .then(response => response.json())
    .then(data => {
        if (data.success) {
            // Hide cart content and show checkout form
            document.getElementById('cartContent').style.display = 'none';
            document.getElementById('checkoutContent').innerHTML = data.data.html;
            document.getElementById('checkoutContent').style.display = 'block';

            // Initialize WooCommerce checkout scripts
            initializeCheckoutScripts();

            // Toggle buttons
            document.getElementById('proceedToCheckoutButton').style.display = 'none';
            document.getElementById('goBackToCartButton').style.display = 'block';
        } else {
            console.error('Error loading checkout form:', data);
        }
    })
    .catch(error => console.error('AJAX error:', error));
}

function goBackToCart() {
    // Show cart content and hide checkout form
    document.getElementById('cartContent').style.display = 'block';
    document.getElementById('checkoutContent').style.display = 'none';

    // Toggle buttons
    document.getElementById('proceedToCheckoutButton').style.display = 'block';
    document.getElementById('goBackToCartButton').style.display = 'none';
}

function initializeCheckoutScripts() {
    if (typeof jQuery !== 'undefined' && typeof wc_checkout_params !== 'undefined') {
        jQuery('body').trigger('update_checkout');
        jQuery('form.checkout').wc_checkout_form();
    } else {
        console.error('WooCommerce checkout scripts are not available.');
    }
}

3. PHP Function to Handle AJAX Request (functions.php):

function load_checkout_form() {
    ob_start();
    echo do_shortcode('[woocommerce_checkout]');
    $html = ob_get_clean();
    wp_send_json_success(['html' => $html]);
    wp_die();
}
add_action('wp_ajax_load_checkout_form', 'load_checkout_form');
add_action('wp_ajax_nopriv_load_checkout_form', 'load_checkout_form');

4. Enqueue WooCommerce Scripts and Styles (functions.php):

function enqueue_woocommerce_scripts() {
    // Enqueue WooCommerce styles
    wp_enqueue_style('woocommerce-general');
    wp_enqueue_style('woocommerce-layout');
    wp_enqueue_style('woocommerce-smallscreen');

    // Enqueue WooCommerce scripts
    wp_enqueue_script('wc-checkout');
}
add_action('wp_enqueue_scripts', 'enqueue_woocommerce_scripts');

Problem:

  • When I click “Proceed to Checkout,” the modal remains empty or shows the raw HTML structure of the checkout blocks without rendering the form.
  • The checkout form doesn’t function correctly, and necessary scripts don’t seem to initialize.
  • window.wc or window.wc.checkout is undefined, so I can’t initialize the checkout scripts properly.

What I’ve Tried:

  • Ensured WooCommerce scripts and styles are enqueued.
  • Attempted to initialize the checkout scripts after loading the form.
  • Checked for JavaScript errors; none are present.

Additional Information:

  • Using the latest version of WooCommerce.
  • Custom one-page theme.
  • Modal implemented with Bootstrap 5.
  • Prefer not to use jQuery, but WooCommerce scripts depend on it.

Question:

How can I properly load the WooCommerce checkout form into a modal via AJAX, ensuring all necessary scripts are initialized so the form renders and functions correctly?

Is there a recommended way to achieve this, or are there limitations with loading the WooCommerce checkout form via AJAX into a modal?

Any help would be appreciated.

How do I change the values of a DT’s filtering sliders in R Shiny with JavaScript?

I’d like to modify the values of the filtering sliders produced by DT in JavaScript. I want to change these values rather than filter the data elsewhere as, ultimately, I want to add presets so you can quickly and easily update the sliders with specific ranges and they will be displayed right above the sliders.

Using runjs() I’ve successfully selected the slider’s elements as follows:

slider = document.querySelectorAll('.noUi-target')[0];

However, my attempts to set or modify the values of the slider have not been successful. The slider seems to be some form of a noUiSlider, but the examples I’ve seen of setting such a slider’s values have not worked here. My attempts include the following, the first of which worked for a shinyWidgets::noUiSliderInput():

slider.noUiSlider.set([10.4, 20])
slider.noUiSlider('options').set([10.4, 20])
slider.setValue([10.4, 20])

I wondered if I needed to import the noUiSlider JS library somehow, or if the slider isn’t rendered as a noUiSlider or slider at all? Here’s a sample app that lays out the basic structure of what I want to do: When the filterOutHighMPG button is clicked, I want the values of the filtering slider beneath mpg to be set to 10.4 to 20 and the data filtered accordingly.

library(shiny)
library(DT)
library(shinyjs)

ui <- fluidPage(
  useShinyjs(),
  actionButton('filterOutHighMPG', 'Filter Out High MPG'),
  DTOutput('table')
)

server <- function(input, output, session) {
  
  output$table <- renderDT({
    datatable(mtcars, filter = 'top')
  })
  
  observeEvent(input$filterOutHighMPG, {
    # Set mpg filter to [10.4, 20]
    runjs("")
  })
  
}

shinyApp(ui, server)

Thanks very much for any help!

Getting an error when i try to copy texts javascript [closed]

I’m always getting an error, when i try to copy the hashatags here is my codes below

var hashtagbutton = $(this).find('.copyhashtagsbutton');
var tagsli = $(this).find('.tags li');
hashtagbutton.on('click', function() {
  var tagsText = [];
  tagsli.each(function() {
    tagsText.push($(this).text());
  });

  var tagsString = tagsText.join(', ');
  navigator.clipboard.riteText(tagsString).thens(function() {
    var originalText = hashtagbutton.text();
    hashtagbutton.text('Copied');
    setTimeout(function() {
      hashtagbutton.text(originalText);
    }, 1500);
  }).catch(function(err) {
    console.error('Failed to copy text: ', err);
  });
});

Link two maps controls in Google Maps JS API

I have two maps and I would like to link the pan/zoom/gesture controls of both maps so they behave identically as if they were one map. They are the same geographical area on both maps. See the picture. I thought pointer-events: none CSS might work but of course that’s for something else. So how’s what I’m trying to do done?

Here’s a JSFiddle with a working map
https://jsfiddle.net/45gc7j8a/

  albertaMap.addListener("center_changed", () => {
    // LINK MAP SOMEHOW?
    ???

    // Another behaviour I'd like
    window.setTimeout(() => {
        albertaMap.panTo(coordinates);
        map.panTo(coordinates);
    }, 5000);
  });

Map of Canada with Alberta highlighted

Select collectionsMat table rows based on mouse and Shift as Excel

i work with angular material table,my table contains a selection Model to handle the selected All and selected One and contains some columns and some rows.
what i have now that i can select all or select one element and all is good,
what i need is to handle the event Shift click as Excel to select the checkbox as a multiples rows.
and when i select a collection in same time there checkbox will be selected and i have the possibility to uncheck one one i click on it.(i found this behaviour in ag grid table but i need that with mat table )
my Html code is like that :

<ng-container matColumnDef="select">
  <th mat-header-cell *matHeaderCellDef>
    <mat-checkbox 
      id="allCheck" 
      (change)="setAllChekedOrUnchecked($event)"
      [checked]="isAllElementSelected" 
      [indeterminate]="iSsomeElementsSelected">
    </mat-checkbox>
  </th>
  <td mat-cell *matCellDef="let row">
    <mat-checkbox 
      [checked]="row.complete" 
      (click)="oneElementSelected($event, row)">
    </mat-checkbox>
  </td>
</ng-container>
<ng-container matColumnDef="entityCode">
  <th mat-header-cell *matHeaderCellDef>TOUTES</th>
  <td mat-cell *matCellDef="let element" style="cursor: pointer">
    <span (click)="openConfirmationDialog(element)">{{ element.entityCode }}</span>
  </td> 
</ng-container>`

my ts file :

dataSource!: MatTableDataSource<any>;
selection = new SelectionModel<Interclassement>(true, []);
selectedElements: Interclassement[] = [];

setAllChekedOrUnchecked($event: MatLegacyCheckboxChange) {
  this.dataSource.data.forEach(elt => {
    elt.complete = $event.checked;
  });
  this.isAllElementSelected = $event.checked;
  
  if ($event.checked) {
    this.selection.select(...this.dataSource.data);
  } else {
    this.selection.clear();
  }
  
  this.iSsomeElementsSelected = this.someElementsSelected();
}

iSsomeElementsSelected: boolean = false;

someElementsSelected() {
  return this.selection.selected.some(t => t.complete && !this.isAllElementSelected);
}

oneElementSelected($event: any, row: any) {
  if ($event.checked) {
    this.selection.select(row);
  } else {
    this.selection.deselect(row);
  }
  
  row.complete = $event.checked;
  this.isAllElementSelected = this.selection.selected.length === this.dataSource.data.length;
  this.iSsomeElementsSelected = this.someElementsSelected();
}

// Shift+Click logic : but it doesn't work.
lastSelectedId: number | null = null;

getRowRange(idA: number, idB: number): any[] {
  const rows = this.dataSource.data;
  const startIndex = rows.findIndex(row => row.id === idA);
  const endIndex = rows.findIndex(row => row.id === idB);

  if (startIndex === -1 || endIndex === -1) {
    throw new Error('Invalid row range');
  }

  const [from, to] = startIndex < endIndex ? [startIndex, endIndex] : [endIndex, startIndex];
  return rows.slice(from, to + 1);
}

toggleSelection(event: MouseEvent, row: any) {
  if (event.shiftKey && this.lastSelectedId !== null) {
    const rowsToToggle = this.getRowRange(this.lastSelectedId, row.id);
    const shouldSelect = !this.selection.isSelected(rowsToToggle[0]);

    rowsToToggle.forEach(row => {
      if (shouldSelect) {
        this.selection.select(row);
      } else {
        this.selection.deselect(row);
      }
    });
  } else {
    this.selection.toggle(row);
  }

  this.lastSelectedId = row.id;
}

Setting a PHP Cookie within an AJAX Call [duplicate]

I’m pretty new to AJAX so I’m struggling a little with my functionality for my WordPress site.

I have a dropdown list of countries and when a user selects a different country, I would like to update the cookie (which is already set) and therefore the page should load the new cookie without reloading the page.

At the moment I have to hit refresh for this to show the correct country code from using the code below, whereas I’d have hoped AJAX would do this without refreshing the page:

<?php echo "Value is: " . $_COOKIE['country']; ?>

My code is below, but I’m sure some of it may not be needed or is wrong.

JS

$('.single-country-select').on("change", function (e) {
    var country_code_value = $('.single-country-select').val();
    var sendData = {
        action: 'country_change_ajax_function',
        country_code_value: country_code_value
    };

    $.ajax({
        url: ajaxadminurl.ajaxurl,
        type: 'POST',
        data: sendData,
        dataType: 'html',
        cache: false,
        success: function(data) {
            // SET COOKIE HERE??
        }
    });
});

functions.php

function country_change_ajax_function() {
    $country_code_value = $_POST['country_code_value'];
    setcookie('country', $country_code_value, time() + (86400 * 30), '/');
    exit;
}
add_action('wp_ajax_country_change_ajax_function', 'country_change_ajax_function');
add_action('wp_ajax_nopriv_country_change_ajax_function', 'country_change_ajax_function');

I’ve also got some code at the top of my header that sets the cookie automatically:

if(!isset($_COOKIE['country'])) {
    $get_user_country_code = simplexml_load_file("http://www.geoplugin.net/xml.gp?ip=".getRealIpAddr());
    if ($get_user_country_code === false) {
        $user_country_code = 'GB';
        setcookie('country', 'GB', time() + (86400 * 30), '/');
    } else {
        $user_country_code = $get_user_country_code->geoplugin_countryCode;
        setcookie('country', $user_country_code, time() + (86400 * 30), '/');
    }
}

Any help would be much appreciated. Thanks!

What are the differences between .toSorted() and .sort() methods in JavaScript?

I’m trying to understand the differences between the .toSorted() and .sort() methods in JavaScript.

From my research and understanding, here’s what I know so far:

.sort():

The .sort() method sorts the array in place and returns the reference to the same array, meaning the original array is mutated. It accepts an optional compare function to determine the sorting order.

Example:

    const arr = [3, 1, 2];
    arr.sort((a, b) => a - b);
    console.log(arr); // output : [1, 2, 3]

.toSorted():

Based on MDN, the .toSorted() method, returns a sorted copy of the array, leaving the original array intact. Like .sort(), it can take an optional compare function, but it does not mutate the original array.

Example:

    const arr = [3, 1, 2];
    const sortedArr = arr.toSorted((a, b) => a - b);  //returns a new sorted array
    console.log(arr);        // output: [3, 1, 2]  (original array is unchanged !)
    console.log(sortedArr);  // output: [1, 2, 3]

Besides immutability, are there any other significant differences between these two methods?

JSON.stringify surrounding arrays with quotes

I’m trying to send data via REST API from a client to a server, the client is just an HTML page with JavaScript and HTMX in it, the server is Spring Boot. The endpoint accepts POST requests with an object:

public record FileMetadataDTO(Integer availabilityTime, FileDTO[] files) {}

public record FileDTO(String name, String extension, Integer sizeMB) {}

On the client side I have a button that sends the request to the server:

<button id="upload-button"
                hx-post="http://localhost:8080/api/v1/upload/metadata"
                hx-headers='{"Content-Type": "application/json"}'
                hx-ext="json-enc"
                hx-vals='js:{"availabilityTime": 1, "files": getFilesDTO()}'
                style="display: none;">Upload</button>
        <label for="upload-button" style="border: 1px solid #ccc; padding: 6px 12px; cursor: pointer;">Upload files</label>

The getFilesDTO() function returns a stringified array:

function getFilesDTO() {
            let filesDTO = [];
            for (let i = 0; i < tuckedFiles.length; i++) {
                filesDTO.push({
                    name: tuckedFiles[i].name,
                    extension: tuckedFiles[i].name.split('.').pop(),
                    sizeMB: tuckedFiles[i].size / 1024 / 1024
                });
            }
            return JSON.stringify(filesDTO);
        }

But JSON.stringify surrounds the array with quotes and the server cannot deserialize it:

{"availabilityTime":"1","files":"[{"name":"a.txt","extension":"txt","sizeMB":0.00022220611572265625},{"name":"another_file.txt","extension":"txt","sizeMB":0.000003814697265625}]"}

A valid payload would be:

{"availabilityTime":"1","files":[{"name":"a.txt","extension":"txt","sizeMB":0.00022220611572265625},{"name":"another_file.txt","extension":"txt","sizeMB":0.000003814697265625}]}

But I can’t make JSON.stringify do it like that no matter what. I tried it in the console of Chrome and Edge to see if my code is at fault, but JSON.stringify([]) in the console of both browsers returns '[]'.

How can I fix this? I’ve been on multiple websites and can’t find a solution.

jQuery multiselect.js selects all options even they are not visible

  1. I use this plugin to make multiselect more comfortable – http://loudev.com/.
  2. I have also integrated search via quicksearch plugin.
  3. And I have set optgroup can be selected

But I would need, if any query is searched and optgroup is selected, to select only options which were found. If item is not match searched query, it is hidden via style="display: none", so I thought best practice to filter them out is to use :visible selector, but it does not work. I’ve also tried :not(:hidden), but it does not work either.

This is the code, which selects all options when optgroup is clicked.

$selectableOptgroup.find('.ms-optgroup-label').on('click', function(){
  var values = $optgroup.children(':not(:selected, :disabled)').map(function(){ return $(this).val();}).get();
  that.select(values);
});

And I’ve tried to edit this way, but still all options are selected.

$selectableOptgroup.find('.ms-optgroup-label').on('click', function(){
  var values = $optgroup.children(':not(:selected, :disabled, :hidden)').map(function(){ return $(this).val();}).get();
  that.select(values);
});

json_encoded array ajax response interpreted as text

My ajax response seems to be interpreted as text even though the ajax request contains datatype: "json". My understanding is that header line in the php script below should have no effect, and yet it fixes my problem.

Can anyone explain this behavior?

I am calling the following javascript function:

async function ajaxTest() {
  $.ajax({
    url: 'test_ajax_response.php',
    type: 'POST',
    datatype: "json",
    data: {
      'foo': 'bar'
    },
    success: function(response) {
      console.log('first element of returned array: ' + response[0]);
      console.log('length of returned array: ' + response.length);
    }
  });
}

Here is test_ajax_response.php:

<?php
header("Content-Type: application/json", true);                               
$bar = $_POST['foo'];
$my_arr = array($bar);
echo json_encode($my_arr);
?>

The console output is

first element of returned array: bar
length of returned array: 1

If I comment the header line the console output is

first element of returned array: [
length of returned array: 7

Same behavior in Chrome and Firefox.

How to determine the height of word-wrapped text in pdf-lib?

In pdf-lib, it is possible to auto-word-wrap text using a technique outlined here: https://stackoverflow.com/a/77436904/1766230

import { PDFDocument, StandardFonts } from 'pdf-lib';
const doc = await PDFDocument.create();
const font = await doc.embedFont(StandardFonts.TimesRoman);
const page = doc.addPage();
// This will word-wrap fine:
page.drawText(someLongText, { font, size: 20, lineHeight: 25, maxWidth: 200, wordBreaks: [' '] });
// But now what?
// page.moveDown(???);

The problem is you may need to either…

  • Move the y cursor down so that you can write the next line to the page. (page.moveDown)
  • Detect when a new page might be needed — i.e., the height of this wrapped text would go off the bottom of the page — so that you can split up the text and add a new page (doc.addPage).

But there does not seem to be any functions in the documentation that let’s you determine the height of the word-wrapped text you are drawing to the page. font.heightAtSize(size) just gets the height of the font. What can be done?

My Component in React JS application don’t read the Headers from REST-Api – Headers is Empty [duplicate]

I created a Web application built with React.Js and Asp.Net core with C#.

When I do Request from Postman or Swagger I have the headers from Response.
From Swagger:

Request and Response from Swagger

And for the postman is the same result.

In React.js I call my endpoint with the following code:

const res = await fetch(url, options);
const data = await res.json();
console.log("Head " ,res);

My console.log from inspect in app is( the headers is empty):
enter image description here

I do fetch my endpoint with options for Authorization but the Response have empty Headers. Why??

From libary with path node_modulestypescriptliblib.dom.d.tsfetch
And my Fetch:
enter image description here

My program.json

{
  "name": "linkedin",
  "private": true,
  "version": "0.0.0",
  "type": "module",
  "scripts": {
    "dev": "vite",
    "start": "vite preview",
    "lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0",
    "preview": "vite preview",
    "build": "vite build --watch"
  },
  "dependencies": {
    "@cloudinary/react": "^1.13.0",
    "@cloudinary/url-gen": "^1.20.0",
    "@fortawesome/fontawesome-free": "^6.6.0",
    "@fortawesome/fontawesome-svg-core": "^6.6.0",
    "@fortawesome/free-solid-svg-icons": "^6.6.0",
    "@fortawesome/react-fontawesome": "^0.2.2",
    "@react-icons/all-files": "^4.1.0",
    "axios": "^1.6.8",
    "cloudinary": "^2.4.0",
    "cors": "^2.8.5",
    "express": "^4.19.2",
    "mssql": "^10.0.2",
    "multer": "^1.4.5-lts.1",
    "path": "^0.12.7",
    "primeicons": "^7.0.0",
    "primereact": "^10.8.2",
    "react": "^18.2.0",
    "react-datepicker": "^7.3.0",
    "react-dom": "^18.2.0",
    "react-icons": "^5.1.0",
    "react-router-dom": "^6.23.1",
    "watch": "^0.13.0"
  },
  "devDependencies": {
    "@types/react": "^18.2.66",
    "@types/react-dom": "^18.2.22",
    "@vitejs/plugin-react": "^4.2.1",
    "eslint": "^8.57.0",
    "eslint-plugin-react": "^7.34.1",
    "eslint-plugin-react-hooks": "^4.6.0",
    "eslint-plugin-react-refresh": "^0.4.6",
    "vite": "^5.4.0",
    "webpack-dev-server": "^5.0.4"
  }
}

Do you have any solution for my problem?

returning a pdf (TCPDF) with a laravel api

I am moving a laravel app to a laravel api and I have a functionality to create pdfs with TCPDF in the laravel app it works without any problem but when I try to move this functionality to an api I am getting several errors.

  1. the pdf comes empty (this should not be happenning)

  2. the pdf comes without the name (it seems to be)

    //laravel controller code: 
    
     $filename = $odp_volumetrica->codigo . ' L ' . $odp_volumetrica->lote . '.pdf';
     $filename = str_replace(' ', '_', $filename); 
    
     header('Content-Type: application/pdf');
     header('Content-Disposition: inline; filename="' . $filename . '"');
     header('Access-Control-Allow-Origin: *');
     $pdf->Output($filename, 'I'); 
    
    
    //react client code:
         authorizedRequest
         .get('/odps/13/printCoa')
         .then(({ data }) => {
             const blob = new Blob([data], { type: 'application/pdf' });
             window.open(URL.createObjectURL(blob));
         })
         .catch((error) => {
             console.log(error);
         });
    

I would like to know if there is a way to return these pdfs and open them in a new tab in the browser and if possible its name is not a random string.