BibiJs Reader not loading books with images

Hello Stack Overflow community,

I hope you’re all doing well. I’m currently working on a book reading website using Bibi Reader, and I’ve encountered a perplexing issue. Some of the books, particularly those with a significant number of images, are not loading in Bibi Reader.

I’ve tried various troubleshooting steps, including reducing the size of the books, to rule out any potential size-related issues. However, even smaller books with images are failing to load.

If any of you have experience with Bibi Reader or encountered a similar problem, I would greatly appreciate your insights and assistance in resolving this issue. Here is the EPUB book that exhibits the problem, hoping that it might provide more context for diagnosis. I’m also attaching the loading page along with network properties that I am getting.

enter image description here

User authentication for a user in an iframe on a different domain

I’m developing a feature where someone can add a JavaScript snippet to their website, which connects back to my server which then loads a website editor for their website in an iframe.

I have that part working fine but the main functionality I need help with is when an admin user from our system (example.com) clicks a link to edit their website (userwebsite.com), it should trigger the client’s website to open a web-based editor on their website where the editor is loaded in via an iframe.

The website (userwebsite.com) loading this iframe cannot be modified to receive any extra GET or POST data and the URL connecting back to my server cannot have any extra params to it just a static URL (example.com/authorize).

The only way I can think of to authorise this user is by setting a 3rd-party cookie for my domain (example.com/set_cookie) which then gets loaded in via the iframe but since Google is going to be blocking 3rd-party cookies, I don’t know how else to authorise this user and make sure the editor doesn’t load for other users on their website but only for the user that clicked the link.

Error: Cannot find module ‘node:util’ when trying to use “sharp”

After I installed sharp to my Node.js application and tried to use it, the following error shows:

/Users/username/Documents/GitHub/Synto-BE/node_modules/sharp/lib/constructor.js:1
Error: Cannot find module 'node:util'
Require stack:
- /Users/username/Documents/GitHub/Synto-BE/node_modules/sharp/lib/constructor.js
- /Users/username/Documents/GitHub/Synto-BE/node_modules/sharp/lib/index.js
- /Users/username/Documents/GitHub/Synto-BE/controller/general/tools.js
- /Users/username/Documents/GitHub/Synto-BE/controller/administration/interview.js
- /Users/username/Documents/GitHub/Synto-BE/services/admin.js
- /Users/username/Documents/GitHub/Synto-BE/routes/index.js
- /Users/username/Documents/GitHub/Synto-BE/index.js
    at Object.<anonymous> (/Users/username/Documents/GitHub/Synto-BE/node_modules/sharp/lib/constructor.js:6:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/username/Documents/GitHub/Synto-BE/node_modules/sharp/lib/constructor.js',
    '/Users/username/Documents/GitHub/Synto-BE/node_modules/sharp/lib/index.js',
    '/Users/username/Documents/GitHub/Synto-BE/controller/general/tools.js',
    '/Users/username/Documents/GitHub/Synto-BE/controller/administration/interview.js',
    '/Users/username/Documents/GitHub/Synto-BE/services/admin.js',
    '/Users/username/Documents/GitHub/Synto-BE/routes/index.js',
    '/Users/username/Documents/GitHub/Synto-BE/index.js'
  ]
}

Node.js v18.17.1
[nodemon] app crashed - waiting for file changes before starting...

Disabling the part of code using sharp doesn’t work, only uninstalling it works for me.

May someone tell me how to install it correctly?

JS: Execute multiple other cases inside of a case

So it is possible to fall-through the case to another case:

switch(variable) {
  case 1:
    // do something 1
  case 2:
    // do something 2
    break;
  case 3:
    // do something 3
    break;
}

But what if we would want to execute multiple other cases after finishing the main case, or execute other case that is not directly after the main case?
Pseudocode for example:

switch(variable) {
  case 1:
    // do something 1
    break;
  case 2:
    // do something 2
    break;
  case 3:
    // do something 3
    execute case 2;
    execute case 1;
    break;
}

I’ve researched the option of labeled statements, but it’s not gonna work here it seems.
The only option I see here is to create new function for every case, but I’m wondering – is there better, cleaner, more readable and/or shorter option?

I’m looking for all tips – be it some keyword I’m missing, your personal tips to do it cleanly, or libraries and even propositions from other languages like typescript etc.

What is Stackoverflow? [closed]

Amidst the verdant hills, where the sun’s golden rays kissed the dew-drenched leaves, there existed a quaint hamlet named Willowbrook. Its cobblestone streets wound like ancient secrets, leading to cozy cottages adorned with ivy and roses. The air was thick with the heady scent of petrichor, a reminder of last night’s rain. In the heart of the village stood an old oak tree, its gnarled branches reaching skyward, as if yearning to touch the heavens.

The villagers were a curious mix—some whimsical, others pragmatic. Mrs. Abernathy, the baker, possessed a mellifluous laugh that echoed through her shop, while Mr. Hawthorne, the reclusive artist, painted nebulous landscapes that seemed to shift with the changing seasons. Children played hide-and-seek in the meadows, their laughter a cacophony that danced on the breeze.

As twilight descended, the tavern came alive. The innkeeper, a sycophant to tales of yore, regaled patrons with stories of enchanted forests and elusive creatures. The hearth crackled, casting shadows on the walls, and the patrons leaned in, their eyes wide with wonder. Outside, fireflies wove intricate patterns, illuminating the night.

Willowbrook held secrets—of lost love letters hidden beneath floorboards, of whispered promises made under moonlit skies. And as the stars blinked into existence, the village settled into its idyllic rhythm, a quintessential haven where time flowed like honey, sweet and slow.

Feel free to explore the nooks and crannies of Willowbrook, where magic and reality entwined in delicate harmony.

Trying to move a range input with javascript in react [duplicate]

I have a range input with a react component, it’s only moving the slider. not triggering the callback function that’s there onChange

const volumeResetHandler = async () => {
  document.querySelector('input[type=range]').value = 0;
}
<input
 className="slider_input"
 type="range"
 value={slv}
 min="0"
 max="600"
 step="10"
 autoFocus
 onChange={volumeChangeHandler}
/>
<h3 onClick={volumeResetHandler} className="cursor-pointer">Reset to default</h3>

I was expecting volumeChangeHandler would get triggered on document.querySelector('input[type=range]').value = 0; but it doesn’t

All soutions mentioned here suffers from same issue

Backend vs Frontend approach for upload of large files to remote storage [duplicate]

I am creating a software involving content delivery. It involves upload of large video files(100GB+).

I understand that in general for file upload you can use the input element of html and upload it to the backend and from there you upload it to your storage.

But this involves 2 uploads for 1 file and involves loading your large file into in-memory database in your backend.

Im wondering if one could save some bandwidth and time, space and computation by somehow directly uploading from the frontend.

What is the industry standard for dealing such a scenario?

I’ve seen ways to upload large files from backend using multipart uploads using AWS sdk, but so far, I couldn’t find a way to directly upload using HTML + JavaScript from the frontend itself(without loading the file into the in-memory database).

I am using Django for backend, Angular for frontend and AWS s3 for storage.

Azure Service Bus – ReceiveMode Peerlock undefined

The ReceiveMode property is always undefined.
The steps I have followed to troubleshoot the issue:

  • clean npm cache/delete node_modules/*.lock file
  • installing/verifying the latest node version
  • testing with a minimal example
  • The debugger on vscode shows peerLock and receiveAndDelete property as available, but it still ends up with an undefined error.

Note: CreateSender and createMessageBatch code works perfectly; ReceiveMode is not working.

Code Sample:

const { ServiceBusClient, ReceiveMode } = require("@azure/service-bus");

async function main() {
    // Create a Service Bus client using the connection string to the Service Bus namespace
    const sbClient = new ServiceBusClient(connectionString);

    // Define topicName and subscriptionName
    const topicName = "your_topic_name";
    const subscriptionName = "your_subscription_name";

    // Create a receiver for the subscription
    const receiver = sbClient.createReceiver(topicName, subscriptionName, {
        receiveMode: ReceiveMode.peekLock,
        prefetchCount: 100, // Set the prefetch count to fetch 100 messages in advance
    });

    // Function to handle messages
    const myMessageHandler = async (messages) => {
        try {
            for (const message of messages) {
                console.log(`Received message: ${message.body}`);
                // Process the message here...
                // Complete the message to remove it from the subscription
                await message.complete();
            }
        } catch (error) {
            console.error("An error occurred while processing the messages:", error);
            // Abandon the messages if processing failed to allow them to be processed again
            for (const message of messages) {
                await message.abandon();
            }
        }
    };

    // Function to handle any errors
    const myErrorHandler = async (error) => {
        console.error("An error occurred while receiving messages:", error);
    };

    // Subscribe and specify the message and error handlers
    receiver.subscribe({
        processMessage: myMessageHandler,
        processError: myErrorHandler
    });

    console.log("Receiving messages...");

    // Wait for a certain duration before closing the receiver and Service Bus client
    await new Promise(resolve => setTimeout(resolve, 60000)); // Wait for 60 seconds

    // Close the receiver and Service Bus client
    await receiver.close();
    await sbClient.close();
}

// Call the main function
main().catch((err) => {
    console.error("Error occurred: ", err);
    process.exit(1);
});

How to format an input as the user types?

I was looking for some more efficient methods on how to format an input as the user types in both a key event and the standard input event, but I found many ideas confusing, using loops and other unnecessary actions.

Well, that’s my view, I’m publishing the question and I’ll be solving it with my answer, if anyone has a good idea you can also post it. Imagine I decide to format this 123456789 to this 123.456.78-9 or (123) 456 789.

How to use JavaScript’s sql-formatter library to parse a SQL statement that contains the nested concat function in the where condition

I want to implement a formatted SQL function on the front end. Among them, SQL may contain some mybatis-specific syntax, such as ‘#{var}’.
The input is SQL compressed into one line; the output is formatted SQL.
The figure below is an example of input and output:
figure of input and output example
input example:

select distinct a.name_order as "nameorder", #{authId}  as "authid", trim(authType) as "authType", concat('org-', a.org_icon) as "iconCls" from table_user a left join (select b.obj_type, b.obj_id from table_object a left join table_auth_data b on a.auth_id = b.id where a.auth = aa) b on (b.obj_type = trim(a.auth_type) and b.object_id = aa)  where a.parent is null and trim(c.org_id) = #{org_Id} order by a.order asc

However, when I add the nested concat() function to the where part of the SQL statement, the parsing will fail, such as:

errer 1:
input

select distinct a.name_order as "nameorder", #{authId}  as "authid", trim(authType) as "authType", concat('org-', a.org_icon) as "iconCls" from table_user a left join (select b.obj_type, b.obj_id from table_object a left join table_auth_data b on a.auth_id = b.id where a.auth = concat('a', concat('b', 'c'))) b on (b.obj_type = trim(a.auth_type) and b.object_id = aa)  where a.parent is null and trim(c.org_id) = #{org_Id} order by a.order asc

The error message is very long:

nearley.js:343 Uncaught Error: Parse error at token: ) at line 1 column 309
Unexpected CLOSE_PAREN token: {"type":"CLOSE_PAREN","raw":")","text":")","start":308}. Instead, I was expecting to see one of the following:

A PROPERTY_ACCESS_OPERATOR token based on:
    property_access → atomic_expression _ ● %PROPERTY_ACCESS_OPERATOR _ property_access$subexpression$1
    atomic_expression$subexpression$1 →  ● property_access
    atomic_expression →  ● atomic_expression$subexpression$1
    asteriskless_andless_expression$subexpression$1 →  ● atomic_expression
    asteriskless_andless_expression →  ● asteriskless_andless_expression$subexpression$1
    asteriskless_free_form_sql$subexpression$1 →  ● asteriskless_andless_expression
    asteriskless_free_form_sql →  ● asteriskless_free_form_sql$subexpression$1
    free_form_sql$subexpression$1 →  ● asteriskless_free_form_sql
    free_form_sql →  ● free_form_sql$subexpression$1
    other_clause$ebnf$1 → other_clause$ebnf$1 ● free_form_sql
    other_clause → %RESERVED_CLAUSE ● other_clause$ebnf$1
    clause$subexpression$1 →  ● other_clause
    clause →  ● clause$subexpression$1
    expressions_or_clauses$ebnf$2 → expressions_or_clauses$ebnf$2 ● clause
    expressions_or_clauses → expressions_or_clauses$ebnf$1 ● expressions_or_clauses$ebnf$2
    statement →  ● expressions_or_clauses statement$subexpression$1
    main$ebnf$1 → main$ebnf$1 ● statement
    main →  ● main$ebnf$1
A LINE_COMMENT token based on:
    comment →  ● %LINE_COMMENT
    _$ebnf$1 → _$ebnf$1 ● comment
    _ →  ● _$ebnf$1
    property_access → atomic_expression ● _ %PROPERTY_ACCESS_OPERATOR _ property_access$subexpression$1
......Due to character limit, some error messages are omitted here.
A RESERVED_JOIN token based on:
    keyword$subexpression$1 →  ● %RESERVED_JOIN
    keyword →  ● keyword$subexpression$1
    atomic_expression$subexpression$1 →  ● keyword
    atomic_expression →  ● atomic_expression$subexpression$1
    asteriskless_andless_expression$subexpression$1 →  ● atomic_expression
    asteriskless_andless_expression →  ● asteriskless_andless_expression$subexpression$1
    asteriskless_free_form_sql$subexpression$1 →  ● asteriskless_andless_expression
    asteriskless_free_form_sql →  ● asteriskless_free_form_sql$subexpression$1
    free_form_sql$subexpression$1 →  ● asteriskless_free_form_sql
    free_form_sql →  ● free_form_sql$subexpression$1
    other_clause$ebnf$1 → other_clause$ebnf$1 ● free_form_sql
    other_clause → %RESERVED_CLAUSE ● other_clause$ebnf$1
    clause$subexpression$1 →  ● other_clause
    clause →  ● clause$subexpression$1
    expressions_or_clauses$ebnf$2 → expressions_or_clauses$ebnf$2 ● clause
    expressions_or_clauses → expressions_or_clauses$ebnf$1 ● expressions_or_clauses$ebnf$2
    statement →  ● expressions_or_clauses statement$subexpression$1
    main$ebnf$1 → main$ebnf$1 ● statement
    main →  ● main$ebnf$1

    at T.O.feed (nearley.js:343:27)
    at Object.parse (createParser.ts:33:34)
    at CA.parse (Formatter.ts:37:49)
    at CA.format (Formatter.ts:31:22)
    at tA (sqlFormatter.ts:96:57)
    at Module.sA (sqlFormatter.ts:69:10)
    at formatSQL (mybatis-xml - 副本.html:68:33)
    at HTMLButtonElement.<anonymous> (mybatis-xml - 副本.html:62:30)

============================================
error 2:
input

select distinct a.name_order as "nameorder", #{authId}  as "authid", trim(authType) as "authType", concat('org-', a.org_icon) as "iconCls" from table_user a left join (select b.obj_type, b.obj_id from table_object a left join table_auth_data b on a.auth_id = b.id where a.auth = concat(trim(a), concat('b', 'c'))) b on (b.obj_type = trim(a.auth_type) and b.object_id = aa)  where a.parent is null and trim(c.org_id) = #{org_Id} order by a.order asc

The error message:

nearley.js:343 Uncaught Error: Parse error at token: ) at line 1 column 313
Unexpected CLOSE_PAREN token: {"type":"CLOSE_PAREN","raw":")","text":")","start":312}. Instead, I was expecting to see one of the following:

A PROPERTY_ACCESS_OPERATOR token based on:
    property_access → atomic_expression _ ● %PROPERTY_ACCESS_OPERATOR _ property_access$subexpression$1
    atomic_expression$subexpression$1 →  ● property_access
    atomic_expression →  ● atomic_expression$subexpression$1
    asteriskless_andless_expression$subexpression$1 →  ● atomic_expression
    asteriskless_andless_expression →  ● asteriskless_andless_expression$subexpression$1
    asteriskless_free_form_sql$subexpression$1 →  ● asteriskless_andless_expression
    asteriskless_free_form_sql →  ● asteriskless_free_form_sql$subexpression$1
    free_form_sql$subexpression$1 →  ● asteriskless_free_form_sql
    free_form_sql →  ● free_form_sql$subexpression$1
    other_clause$ebnf$1 → other_clause$ebnf$1 ● free_form_sql
    other_clause → %RESERVED_CLAUSE ● other_clause$ebnf$1
    clause$subexpression$1 →  ● other_clause
    clause →  ● clause$subexpression$1
    expressions_or_clauses$ebnf$2 → expressions_or_clauses$ebnf$2 ● clause
    expressions_or_clauses → expressions_or_clauses$ebnf$1 ● expressions_or_clauses$ebnf$2
    statement →  ● expressions_or_clauses statement$subexpression$1
    main$ebnf$1 → main$ebnf$1 ● statement
    main →  ● main$ebnf$1
A LINE_COMMENT token based on:
    comment →  ● %LINE_COMMENT
    _$ebnf$1 → _$ebnf$1 ● comment
    _ →  ● _$ebnf$1
    property_access → atomic_expression ● _ %PROPERTY_ACCESS_OPERATOR _ property_access$subexpression$1
    atomic_expression$subexpression$1 →  ● property_access
    atomic_expression →  ● atomic_expression$subexpression$1
    asteriskless_andless_expression$subexpression$1 →  ● atomic_expression
    asteriskless_andless_expression →  ● asteriskless_andless_expression$subexpression$1
    asteriskless_free_form_sql$subexpression$1 →  ● asteriskless_andless_expression
    asteriskless_free_form_sql →  ● asteriskless_free_form_sql$subexpression$1
    free_form_sql$subexpression$1 →  ● asteriskless_free_form_sql
    free_form_sql →  ● free_form_sql$subexpression$1
    other_clause$ebnf$1 → other_clause$ebnf$1 ● free_form_sql
    other_clause → %RESERVED_CLAUSE ● other_clause$ebnf$1
    clause$subexpression$1 →  ● other_clause
    clause →  ● clause$subexpression$1
    expressions_or_clauses$ebnf$2 → expressions_or_clauses$ebnf$2 ● clause
    expressions_or_clauses → expressions_or_clauses$ebnf$1 ● expressions_or_clauses$ebnf$2
    statement →  ● expressions_or_clauses statement$subexpression$1
    main$ebnf$1 → main$ebnf$1 ● statement
    main →  ● main$ebnf$1
......Due to character limit, some error messages are omitted here.

    at T.O.feed (nearley.js:343:27)
    at Object.parse (createParser.ts:33:34)
    at CA.parse (Formatter.ts:37:49)
    at CA.format (Formatter.ts:31:22)
    at tA (sqlFormatter.ts:96:57)
    at Module.sA (sqlFormatter.ts:69:10)
    at formatSQL (mybatis-xml - 副本.html:68:33)
    at HTMLButtonElement.<anonymous> (mybatis-xml - 副本.html:62:30)
T.O.feed @ nearley.js:343
parse @ createParser.ts:33
parse @ Formatter.ts:37
format @ Formatter.ts:31
tA @ sqlFormatter.ts:96
sA @ sqlFormatter.ts:69
formatSQL @ mybatis-xml - 副本.html:68

===========================================================

Complete code:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>SQL parse</title>
    <style>
        .container {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: space-around;
            margin-top: 10px;
        }

        .xml-container {
            padding: 10px;
            width: 75%;
            overflow: auto;
        }

        .xml-container pre {
            font-size: 18px;
            min-height: 40px;
            border: 1px solid #ccc; 
            padding: 10px; 
            overflow-y: auto; 
        }
    </style>
</head>

<body>
    <div class="container">
        <div class="xml-container">
            <pre id="originalXml" contenteditable></pre>
        </div>
        <button id="parseButton">parse SQL</button>
        <div class="xml-container">
            <h3>parsed data</h3>
            <pre id="parsedData" style="font-size: 18px;"></pre>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/sql-formatter/dist/sql-formatter.min.js"></script>
    <script>

        var parseButton = document.getElementById("parseButton");

        var originalXmlPre = document.getElementById("originalXml");

        var loopParsedDataPre = document.getElementById("parsedData");

        parseButton.addEventListener("click", function () {

            var xmlString = originalXmlPre.textContent;
            var parsedData = formatSQL(xmlString);
            loopParsedDataPre.textContent = parsedData;

        });

        function formatSQL(sql) {
            return sqlFormatter.format(sql, {
                language: 'sql',
                paramTypes: {
                    custom: [
                        { regex: String.raw`#{(.+?)}`},

                        { regex: String.raw`trim(.+?)`, flags: 'i'},
                        
                        { regex: String.raw`concat(.+?)`, flags: 'i'}, 

                        { regex: String.raw`concat(.+?)`, flags: 'i'}, 

                        { regex: String.raw`concat.+?concat.+?))`, flags: 'i'}, 

                        { regex: String.raw`concat(.+?)concat(.+?)`, flags: 'i'}, 
                        
                    ],
                },
            });
        }
    </script>
</body>

</html>

my attempt:

I tried to use the custom regular function of sqlFormatter to solve the problem, but at best it could only solve a simple concat(). It completely failed for nested concat() and concat() containing trim().
Regular definition code:

function formatSQL(sql) {
            return sqlFormatter.format(sql, {
                language: 'sql',
                paramTypes: {
                    custom: [
                        { regex: String.raw`#{(.+?)}`},

                        { regex: String.raw`trim(.+?)`, flags: 'i'},
                        
                        { regex: String.raw`concat(.+?)`, flags: 'i'}, 

                        { regex: String.raw`concat(.+?)`, flags: 'i'}, 

                        { regex: String.raw`concat.+?concat.+?))`, flags: 'i'}, 

                        { regex: String.raw`concat(.+?)concat(.+?)`, flags: 'i'}, 
                        
                    ],
                },
            });
        }

How to keen the “r” characters in a string without any carrige return [closed]

I have an array where each element represents some text in a given language.
One of the languages is Coptic. Some of the text incudes the “r” characters as part of the language charcters (which the CSS font interprets into some Coptic letter when the text is rendred in an html element):

example:

"`mmoc nN`èrhi de 'en pi`èabot `èmma"

The “r” in “èrhi” represents some Coptic character not a carrige return.

I tried replacing r by \r in my string. I also tried to replace it by \r. It didn’t work.

How to force javascript to deal with “r” as normal string and ignore the escape characther before the letter “r”?

Getting 400 Bad Request Error When Making POST Request to obtain JWT Token Using HttpService in NestJS

I’m developing a NestJS application where I need to obtain a JWT token by making a POST request. I’m utilizing the HttpService from the @nestjs/common library. However, I consistently encounter a 400 Bad Request error.

Here’s the code using HttpService to get JWT token:

import {
  HttpService,
  InternalServerErrorException,
} from "@nestjs/common";


export class JwtService {
 constructor(private httpService: HttpService, private cache: CacheService) {}
private getAuthToken(): Observable<OAuth> {
    const url = 'endpoint_url';
    const body = JSON.stringify({
      "client_id": 'XXXXXXXXXXXXXXX',
      "client_secret": 'XXXXXXXXXXXXX',
      "grant_type": "client_credentials",
    });

    const headers = { "Content-Type": "application/json" };
    return this.callAPI(url, body, headers);
  }

private callAPI(
    url: string,
    body,
    headers: { [key: string]: string }
  ): Observable<any> {
        return this.httpService.post(url, body, headers).pipe(
          map((result: AxiosResponse<any>) => result.data),
          tap((result: any) => {
            const { access_token } = result; // eslint-disable-line
            this.cache
              .set("authToken", access_token, {
                ttl: env.SECONDS_TO_EXPIRE,
              })
              .subscribe();
          }),
          catchError((err: any) => {
            return throwError(
              new InternalServerErrorException(err.message, "Auth Service")
            );
          })
        );
      })
  }
}
}

Here’s what I’ve already tried:

  1. Other APIs: I tested the same code with other APIs, and it worked flawlessly. The issue seems specific to the JWT token API.
  2. Postman Success: When I manually send the request using Postman (same URL, body, and headers), I successfully receive the token.
  3. Body Format: I attempted using a plain object for the request body instead of a JSON object, but the error persists.
  4. Fetch API: I also experimented with the fetch() API, and it returned the expected response (code snippet below).

Sample code using fetch api:

const req = {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        client_id: XXXXXXXXXX,
        client_secret: XXXXXXXXXXX,
        grant_type: XXXXXXXXXXX,
      }),
    };
    fetch('jwt_token_endpoint', req)
      .then((response) => response.json())
      .then((data) => {
        this.logger.log(`Success retrieving jwt token`);
        console.log(data);
        this.jwtSubject.next(`${data.token}`);
      })
      .catch((error) => {
        this.logger.error(`Error retrieving jwt token: ${error}`);
      });

I am looking for an assistance to resolve the error and get the token successfully.

How to loop through data a certain number of times in Svelte

I’ve successfully connected my app to supabase – and it’s fetching data from a table I’ve recently setup.

I’ve got the law-firm names appearing in a card template, so there’s a seperate card for each h3 being pulled in.

I want to be able to loop through my database, and after fetching 4 sets of data (the law-firm name) I want to create a duplicate row underneath – fetch another 4 and continue this way (I’ll sort out the pagination at a later date).

Any help would be appreciated as this is the first time I’ve used Svelte – and I’ve gone through multiple SO posts, as well as the svelte-kit documentation.

<script>
    export let data;
</script>

<ul class="flexCards">
    {#each visibleLawFirms as LawF}
        <li class="cardShape">
            <h3>{LawF.lawfirmname}</h3>
        </li>
    {/each}
</ul>

Need an anchor tag to download a binary file inside a td table cell

I’m trying to achieve something like I’ve shown in the image.

When an user clicks on that anchor tag, a fileselector should appear and binary (.bin) file has to get downloaded in the location where user selects. (https://i.stack.imgur.com/OGhw1.png)

I’ve created ‘a’ tag, and set all the attributes like ‘download’, ‘filename’ etc.
But, I’m not able to download it. I’m implementing it in a webview of VSCode extension.

I don’t want to post the complete code as previously question got closed due to some confusion. So, please help me with the ways/code to achieve this from scratch. Thanks in advance.