Uploading video files and subtitle files to MongoDB

// backend/server.ts
import express, { Application, Request, Response } from 'express';
import mongoose from 'mongoose';
import cors from 'cors';
import dotenv from 'dotenv';
const multer  = require('multer')
const upload = multer({ dest: 'uploads/' })
const { mongoDBURL } = require('./config');

dotenv.config();

const app: Application = express();

// Middleware
app.use(cors());
app.use(express.json());

// Database connection
const MONGODB_URI = mongoDBURL;

mongoose.connect(MONGODB_URI)
.then(() => console.log("MongoDB connection established"))
.catch(error => console.error("MongoDB connection failed:", error.message));

// Routes
app.get('/', (req: Request, res: Response) => {
  res.send('Hello from Express + TypeScript Server');
});

// Start server
const PORT: number | string = process.env.PORT || 5001;
app.listen(PORT, () => {
  console.log(`Server is running on port: ${PORT}`);
});

app.post('/upload', upload.fields([{ name: 'video', maxCount: 1 }, { name: 'subtitle', maxCount: 1 }]), (req: Request, res: Response) => {
  const files = (req as any).files; // Use type assertion here
  if (files) {
    res.send({ message: 'Files uploaded successfully.', files: files });
  } else {
    res.status(400).send({ message: 'File upload failed.' });
  }
});

I am attempting to upload 1 video file and 1 subtitle file at the same time to my mongo database. I am very new to this so I am sorry if my code is gross. When I try and upload the files I get a console message saying it was successful and shows me some of the data.

const UploadComic: React.FC = () => {
  // State to store the uploaded files
  const [videoFile, setVideoFile] = useState<File | null>(null);
  const [subtitleFile, setSubtitleFile] = useState<File | null>(null);

  // Handlers for file selection
  const handleVideoFileSelect = (file: File | null) => {
    setVideoFile(file);
  };

  const handleSubtitleFileSelect = (file: File | null) => {
    setSubtitleFile(file);
  };

  // Inside your component
  const handleAddToLibrary = () => {
    if (!videoFile || !subtitleFile) {
      alert('Missing files');
      return;
    }
  
    const formData = new FormData();
    formData.append('video', videoFile); // Assuming 'video' is the field name expected by the server
    formData.append('subtitle', subtitleFile); // Assuming 'subtitle' is the field name expected by the server
  
    axios.post('http://localhost:5001/upload', formData, {
      headers: {
        'Content-Type': 'multipart/form-data',
      },
    })
    .then((response) => {
      console.log('Files uploaded successfully1', response.data);
      // Handle success
    })
    .catch((error) => {
      console.error('Error uploading files', error);
      // Handle error
    });
  };

Im not sure what im doing wrong but it will not upload to mongodb, It did one time but I could not replicate what happened. If you have any suggestions or even if my code is bad that would be helpfup too, it is important to note i have asked chatgpt for help so any random code could be caused by that.

I have tried a couple different ways but I was expecting it to upload or to throw an error but neither happened.

Display 5 digit Julian Date in IFRAME

I have a locally hosted (on my machine) simple HTML page that we use in the office for tracking work orders. I made it as simple as possible. One dynamic element I need is to display the 5 digit Julian date inside of an IFRAME.

The format needs to be (ex): 24043
24 for the last two of the year, and 043 being the 43rd day of this calendar year (February 12, 2024).

I have tried multiple different posts, and guides to get this working, but none of them thus far has worked correctly, or most times, at all.

Here is the code I have in my HEAD at the moment:

<script type="text/javascript">
document.getElementById('txt').julianDate;
//set an array with day counts for all months
var dayCount = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

function convertDate(str) {
   //convert passed string to date object
   var dte = new Date(str);
   //initialize date variable
   var julianDate = 0;
   //add days for previous months
   for (i = 0; i < dte.getMonth(); i++) {
      julianDate += dayCount[i];
   }
   //add days of the current month
   julianDate += dte.getDate();
   //check for leap year
   if (dte.getFullYear() % 4 == 0 && dte.getMonth() > 1) {
      julianDate++;
   }
   //alert("Julian Date: " + julianDate);
   //var jdate = julianDate
   //return julianDate;
   document.getElementById("JulianDate").innerHTML = julianDate2
}
</script>

And in the body (as a test) I have this:

<h1>"The value for number is: " <span id="JulianDate2"></span></h1>

My current output is:

“The value for number is: “

with no value being put out. I’m not a programming whiz by any means, so I have to look most of this up, and work my way though it the best I can.

Unable to resize elements if the height and width of the element are set

I have a very unique use-case that I am unable to find a suitable solution for. I am recursively building a grid using angular. The grid is comprised of rows which contain columns (which contain a nested set of rows and columns and so forth). When a column contains a component, it is dynamically rendered and displayed on the screen resulting in a layout.

I need to find a way to make the rows and columns resizable. When I came across the “resize”: “vertical” and “horizontal” I thought it would solve my problem. However, when I load the layout from saved JSON, the sizes are fixed for each of the columns as the layout was already set. This means that the resize will not change the size of the elements as they have a height and width now.

Here is my recursive HTML:

 <div *ngIf="isScreenSelected" [ngClass]="nested ? 'nested-screen-container container' : 'screen-container container'" (click)="disableDefaults($event)">
    <div [ngClass]="getRowClass(nested, row.columns.length, last)"
         *ngFor="let row of screen.rows; let last = last">
      <div [ngClass]="getColumnClass(last)" *ngFor="let column of row.columns; let last = last;" (invoke)="setStyle(column.componentId, column.width, column.height)" cdkDropList
           [cdkDropListConnectedTo]="existingComponentIds"
           [id]="column.componentId"
           (cdkDropListDropped)="drop($event, column)">
        <app-fab-button-menu *ngIf="!column.componentInstance && !(column.nestedScreen.rows.length > 0) && !previewMode"
                             (addColumn)="addColumn(column)"
                             (addRow)="addRow(column)"></app-fab-button-menu>
        <app-page-design [isScreenSelected]="isScreenSelected"
                         [existingComponentIds]="existingComponentIds"
                         [previewMode]="previewMode"
                         [screen]="column.nestedScreen"
                         [nested]="true" cdkDragDropList
                         *ngIf="!column.componentInstance && column.nestedScreen.rows.length > 0"
                         (screenChanged)="onScreenChange()"
                         (functionalComponentAdded)="addFunctionalComponent($event)"></app-page-design>
        <div class="center" *ngIf="column.componentName">
          <app-functional
            [component]="column.componentInstance"
            [model]="column.componentModel"
            [id]="column.id"
            [style]="column.class"
            ></app-functional>
        </div>
      </div>
    </div>

And here is my style including the resize method.

.screen-container {
  background-color: #ffffff;
  width: 75%;
  margin-left: 12.5%;
  margin-top: 7%;
  height: 75%;
  z-index: 2;
  border: 1px solid #f0f0f0;
}

.nested-screen-container {
  background-color: #ffffff;
  width: 100%;
  height: 100%;
  z-index: 2;
  display: flex;
  flex-direction: column;
}

.component-container {
  display: flex;
  justify-content: center;
  align-items: center;
}

.nested-column-border {
  border-style: dotted;
  border-left: hidden;
  border-top: hidden;
  border-bottom: hidden;
  padding-left: unset;
  padding-right: unset;
  border-color: darkgray;
  resize: horizontal !important;
  overflow-x: auto !important;
}

.nested-row-border {
  border-style: dotted;
  border-left: hidden;
  border-top: hidden;
  border-right: hidden;
  padding-left: unset;
  padding-right: unset;
  border-color: darkgray;
  resize: vertical !important;
  overflow-y: auto !important;
}

.col, .col-1, .col-10, .col-11, .col-12, .col-2, .col-3, .col-4, .col-5, .col-6, .col-7, .col-8, .col-9, .col-auto, .col-lg, .col-lg-1, .col-lg-10, .col-lg-11, .col-lg-12, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-lg-auto, .col-md, .col-md-1, .col-md-10, .col-md-11, .col-md-12, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-md-auto, .col-sm, .col-sm-1, .col-sm-10, .col-sm-11, .col-sm-12, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-auto, .col-xl, .col-xl-1, .col-xl-10, .col-xl-11, .col-xl-12, .col-xl-2, .col-xl-3, .col-xl-4, .col-xl-5, .col-xl-6, .col-xl-7, .col-xl-8, .col-xl-9, .col-xl-auto {
  padding-left: unset !important;
  padding-right: unset !important;
}

.center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 10px;
  width: 100%;
  height: 100%;
}

.row {
  flex-wrap: unset !important;
}

.col {
  flex-basis: unset !important;
  flex-grow: unset !important;
  max-height: 100%;
  max-width: 100%;
}

.width-auto {
  width: auto;
  flex-grow: 1 !important;
}

.height-auto {
  flex-grow: 1 !important;
}

.half-height {
  height: 50%;
}

.width-half {
  width: 50%;
  min-width: 0;
}

.div {
  position: unset !important;
  left: unset !important;
}

.app-functional {
  cursor: pointer;
}

::ng-deep .mat-mdc-menu-content, .mat-mdc-menu-content .mat-mdc-menu-item .mat-mdc-menu-item-text {
  display: flex;
}

::ng-deep .mat-mdc-menu-item {
  padding: unset !important;

  min-height: unset !important;
}

::ng-deep .mat-mdc-menu-panel {
  min-width: unset !important;
}

::ng-deep .mat-mdc-menu-item .mat-icon {
  margin-right: 5px !important;
  margin: 5px;
}

::ng-deep .mat-mdc-menu-content {
  padding: unset !important;
  padding-left: 3px !important;
  padding-right: 3px !important;
}


.resizer {
  width: 50px;
  height: 50px;
  background-color: red;
  position: absolute;
  bottom: 0;
  right: 0;
  cursor: se-resize !important;
  z-index: 1000;
}

.resizable {
  position: relative;
  overflow: hidden;
}

TLDR; The long and the short of it is how can I resize: vertical or resize: horizontal for an element that already has a height set. I cannot use min/max-height either as it must be changed.

Add class on click to a unordered list item to change the background color of list item and at the same time remove it from other list item

I am trying to add a class on the unordered list item when I click on it and a the same time it should be removing the same class from other list item.

I have tried using the below JavaScript logic but I am not getting the desired results. When I am including e.preventDefault() then it is not redirecting me to the desired page but it is removing and adding the class to the list item. And when I am excluding e.preventDefault() then it is redirecting me to the desired page but it is not removing and adding the class.
Below is my HTML, CSS and Javascript(index.js)

<div id="user-account-menu">
  <ul class="side-nav"> 
    <li class="">
      <a href="/me">
        Settings
        <img class="navItems-icons" src="img/icons/settings.png" alt="settings">
      </a>
    </li>
    <li class="active">
      <a href="/create-user">
        Create User
        <img class="navItems-icons" src="img/icons/create-user.png" alt="create-user">
      </a>
    </li>
  </ul>
</div>
li:hover:not(.active) {
    background-color: rgb(91, 19, 114);
    border-radius: 2vh;
}

.active {
    background-color: rgb(132, 2, 175);
}
var links = document.querySelectorAll('li');
links.forEach(function (element) {
  element.addEventListener('click', function (e) {
    // PreventDefault to prevent redirect
    e.preventDefault();
    links.forEach(async function (element) {
      // element.preventDefault()
      await element.classList.remove('active');
    });
    this.classList.add('active');
  });
});

Why does my second statement depend on my first statement?

I am building a WordPress theme for a portfolio site. I have this archive page of categories that displays all the posts’ thumbnails + titles. On top of each thumbnail I have a div that says ‘New’ that I only want to display on posts that have the category ‘New’.

Currently, I have a java script with a list of all the <a> tags that link to projects’ urls that DO NOT have the category of ‘New’. Then, I find the div that displays the ‘New’ sticker, inside those <a> tags, and give them a style of ‘display: none’. Here is my code:

HTML

<div class="projects-container">
    <?php while ( have_posts() ) : the_post(); ?>
        <a href="<?php the_permalink() ?>" class="project-link">
            <div class="single-project">
                <div class="new-project-tag-container">
                    <button class="new-project-tag">New</button>
                </div>

                <div class="project-image">
                    <div class="color-duplicate"></div>
                    <?php the_post_thumbnail( ); ?>
                </div>

                <h2>
                    <?php the_title(); ?>
                </h2>
            </div>
        </a>
    <?php endwhile; ?>
</div>
JAVASCRIPT

hideThisProject = [];
    hideThisProject[0] = document.querySelectorAll("a[href='http://localhost:8888/projects/projects/project-0/']")[0];
    hideThisProject[1] = document.querySelectorAll("a[href='http://localhost:8888/projects/projects/project-1/']")[0];

hideThisProject[0].querySelectorAll('.new-project-tag-container')[0].style.display = 'none';
hideThisProject[1].querySelectorAll('.new-project-tag-container')[0].style.display = 'none';

Since I am doing this one element at a time, the second element depends on the existence of the first one. For exemple: if there is a page with both ‘project-0’ and ‘project-1’, it works; if there is a page with ‘project-0’ but no ‘project-1’, it works; but if there is a page with ‘project-1’ but no ‘project-0’, it doesn’t work.

Why does my second statement depend on my first statement, and how can I fix this?

Thank you for your help, in advance.

I wrote a code to fetch an api in javascript but i also got the data back but i am not getting a desired output [duplicate]

For eg –

Const cities=[];

Fetch(api)
.then(response=>response.json())
.then(data=>cities.push(data)) 

I am not getting the desired Array,
I want an Array with the data but I am getting an array with length 1 and index element 0 and also getting the data at the 0th index but when I try to access it with cities[0] I get undefined can someone help me with that?

Select a HTML element containing APOSTROPHE using document.evaluate()

I am trying to select an element containing 1'000 g using document.evaluate(). The issue is the apostrophe. I tried to use u0027, '', ', \' and &#x27;, but those either trigger invalid xpath expression errors or return no elements.

const items1 = document.evaluate(
  "//p[contains(normalize-space(.), '1000u00a0g')]",
  document,
  null,
  XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
  null,
);
console.log("item1", items1.snapshotItem(0).textContent);

const items2 = document.evaluate(
  "//p[contains(normalize-space(.), '1&#x27;000u00a0g')]",
  document,
  null,
  XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
  null,
);
console.log("item2", items2.snapshotItem(0).textContent);
<p>1000&nbsp;g</p>
<p>1'000&nbsp;g</p>

What is the correct way to select an element containing an apostrophe using an xpath expression in document.evaluate()?

, why is xmlhttprequest synchronous deprecated?

I am having trouble understanding the ‘async’ part of XMLHttpRequest().
I have written a website www.weemfg.com using javascript and PHP using
syncronous http which works fine using firefox however when i use chrome
i get warnings about my use of ‘synchronous’ being deprecated. I want
the data returned to my call of majax below. using async it will go
to someplace else and how will i know when it is there. allowing timeout
to synchronous xhttp might solve my problem.

what i want … let rsp = majax(“qry,”select * from sometable”).

function majax(op, argv) {
    /* ------------------------------------------------------------------
      this is synchronous. Since the user has initiated communication
      and this is a single purpose app there is no need for 'async'
      there will always be a rsp[0]
    ------------------------------------------------------------------- */
    //console.log("at majax op="+op+" argv="+argv);
    let pdata = new FormData();
    pdata.append('op', op);
    pdata.append('argv', argv);

    let rsp = false;
    let xhr = new XMLHttpRequest();
    xhr.open('POST', 'mfg.php', false);     // false=synchronous
    xhr.onload = function () {
        rsp = this.responseText;
    }
    xhr.send(pdata);              // this wont return until onload finishes
    return rsp;
}

i have tried to accomplish what i want using async without success.

Why is my CSS animation skipped when using classes and javscript to add elements to the class

This is my first time using CSS animation and what I’m trying to achieve is to have this title bar to shrink out of the way of a sidebar from 100% of the width of the screen (100vw) to 75vw. I’m running this in vanilla CSS and Javascript, there are only two divs under the body in html (topDiv and sidebarDiv) and the issue that I’m facing is that the title bar shrinking animation is not running, the sidebar animation works fine.

The effect that should be achieved is that the sidebar ‘pushes’ the top title bar out of the way when the menubutton (on the title bar) is clicked. The issue I’m encountering is that the animation does not run and that there is a space between the title bar and sidebar until the sidebar finishes its animation and fills in the space between the title bar and the sidebar. Here’s my CSS and JavaScript code:

@keyframes openingSidebar {
    from{transform: translateX(-100%);}
    to{transform: translateX(0%);}
}

@keyframes openingSidebarTitle {
    from{width:100vw;}
    to{width:75vw;}
}

#topDiv {
    background-color: #A167A5;
    height:6vw;
    width:100vw;
}

#textContainer{
    display: flex;
    justify-content: left;
    align-items: center;
    height: 5vw;
}

.sidebar {
    display:none;
    background-color:#A167A5;
    color:#E8D7F1;
    height:100vw;
    width: 20vw;
    overflow:hidden;
    transform: translateX(-100%);
    padding-left:2.5vw;
    padding-right:3vw;
}

.animatedSidebar {
    animation-name: openingSidebar;
    animation-duration:1s;
    animation-timing-function:linear;
}

.shrinkTopBar {
    animation-name:openingSidebarTitle;
    animation-duration:1s;
    animation-timing-function:linear;
}
var sidebarClickedCounter = 0;
var sidebar = document.getElementById("sidebarDiv");
var titleBar = document.getElementById("topDiv");
var sidebarOpen = false;

function openSideMenu(){
    // false = open, true = close  
    if(sidebarClickedCounter % 2){
        console.log("Close sidebar command.")
        sidebar.classList.remove("animatedSidebar");
        titleBar.classList.remove("shrinkTopBar");
        sidebar.style.display = "none";

        titleBar.style.width = "100vw";
        sidebarOpen = false;
    } else {
        console.log("open sidebar command.")
        sidebar.style.display = "flex";
        sidebar.classList.add("animatedSidebar");
        titleBar.classList.add("shrinkTopBar");

        sidebar.style.transform = "translate(0%, 0%)";
        titleBar.style.width = "75vw";
        sidebarOpen = true;
    }
    sidebarClickedCounter++;
}

Create timebased trigger in side a for loop (apps script)

In an apps script project, i have to run a task that will take about 2 hours to complete,
so i decided to break it in parts and run each via timebased trigger.
In the below snippet:
the function longAction represent the function that needs to be run multiple times and this function will accept arguments a and b.

the lowerUpper() function returns a list of ranges[0-4, 5-9, 10-14, 15-19, 20-20], these represent row numbers in a googlesheet.

I tried creating copies of the longAction function using the bind method.
Which in turn i want to use in the ScriptApp timebased c while creating trigger.

Result: The triggers are created (ok).
Problem: I have the following error

Script function not found: function () { [native code] }

How can i correct the error? Or any other way of dealing with the problem.

I expected to create timebased triggers where each trigger runs the same function but with a different set of argument.

I have the following error:
Script function not found: function () { [native code] }


let longAction = function (a,b){
    for(let i =a ; i<= b ; i++){
        Logger.log(i) // for testing purpose
    }
 }

function test(){
    let rng = lowerUpper(20,4) // [0-4, 5-9, 10-14, 15-19, 20-20]

    for (j = 0; j < rng.length ; j++){
        let low = rng[j].split('-')[0]
        let upper = rng[j].split('-')[1]
 
    // create copies of longAction function to    use later in the trigger
        let action1 = longAction.bind(null,low,upper) 

       ScriptApp.newTrigger(action1)
       .timeBased()
       .after(1 * 60 * 1000)
       .create()
    }
}

How do I fix error message while trying to run json-server

After installing the json-server package, while trying to run it on my terminal, I got an error message. I installed the server using the command below:

npm install -g json-server

I then proceeded in running the server using the command below:

json-server -p 8080 -w ./data/db.json

I expected the terminal to return a link to API endpoint but I got the error message below:

/mnt/c/Users/InternetOG/AppData/Roaming/npm/node_modules/json-server/lib/bin.js:2
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
^

SyntaxError: Unexpected token {
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)  
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
at startup (internal/bootstrap/node.js:283:19)

405 – Method not allowed , cant get a solucion

I’m making an webapp. In this webapp im using a webservice that was already made. Before i started to develop this app for the web , i make the exact same in java for android and everything of the post requests worked fine but in this web app it doesen’t. Also in postman works like a charm.
Can someone help me to figure out thats wrong?
Here is my code:

<?php
header("Access-Control-Allow-Origin: *");  
header("Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS");
header("Access-Control-Allow-Headers: Content-Type, Authorization");

session_start();


$totalPrice = 0;
$itemTotal = 0;


if (isset($_SESSION['cart']) && !empty($_SESSION['cart'])) {
    
    echo '<ul>';
    foreach ($_SESSION['cart'] as $key => $item) {
        echo '<li>';
        // Output item details
        // For example:
        echo 'Código: ' . $item['codigo'] . ', ';
        echo 'Descrição: ' . $item['descricao'] . ', ';
        echo 'Preço: ' . $item['preco'] . ', ';
        echo 'Quantidade: ' . $item['quantidade'];
        echo '</li>';
    }
    echo '</ul>';
} else {
    echo 'O carrinho está vazio.';
}

echo '<p>Total a pagar: ' . $totalPrice . '€</p>' . '<br>';


if (isset($_POST['fazerEncomenda'])) {
    
    if (!isset($_SESSION['user_id'])) {
        echo 'Utilizador não está logado.';
        exit;
    }

    
    $userId = $_SESSION['user_id'];

    // THE PARAMETERES ARE FIXED FOR NOW 
    $order = array(
        "FiscalYear" => "2024",
        "SectionCode" => "1",
        "DocTypeAbbrev" => "ENCCL",
        "EntityCode" => 1,
        "Date" => "09/02/2024",
        "ExpirationDate" => "08/12/2024",
        "CurrencyCode" => "EUR",
        "Lines" => array(
            array(
                "LineNumber" => 1,
                "ItemCode" => "1",
                "ItemDescription" => "artigo teste",
                "Quantity" => 1,
                "VATTax" => 23,
                "UnitPriceExcludedVAT" => "1",
                "GetReportBytes" => true
            )
        )
    );

  
    $ch = curl_init('http://myip/ERPV22/api/EncomendarUser/GenerateCustomerOrder');
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($order));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'Content-Type: application/json',
        'Cookie: PHPSESSID=' . session_id() 
    ));

    
    $decodedCookies = urldecode($_SERVER['HTTP_COOKIE']);
    curl_setopt($ch, CURLOPT_COOKIE, $decodedCookies);

    $response = curl_exec($ch);
    echo $response; 
}
?>

<form method="post"> 
    
    <input type="submit" name="fazerEncomenda" value="Fazer Encomenda">
</form>

Thanks for everyone’s help!

PayPal Sandbox always shows amount of transaction is 0.01 (PayPal checkout integration)

PayPal Sandbox always shows amount of transaction is 0.01
Here is my code:

<script src="https://www.paypal.com/sdk/js?client-id=AVzxh6XXXXXXXX9Z-1gHtNyyjBawLvnvJLRrshVSrLjwhqWoPg3FI9PiTdi-..."></script>

<div id="paypal-button-container" style="position:relative;left:25%;width:50%;text-align:center;color:#FFFF00;"></div>

<script>
paypal.Buttons().render('#paypal-button-container')

</script>
<script>
createOrder: function(data, actions) {
return actions.order.create({
"purchase_units": [
{
"amount": {
"currency_code": "USD",
"value": "35.00"
}

}
]
});
}

</script>

the buttons show… i click on Paypal and login to my sandbox personal account in the popup

it shows the amount of the sale as 0.01 why does it not show 35.00

What am i missing..

Thanks in advance for anyone’s help

NOTE: i have tried to ask this on PayPal developer community with no response at all..i am hoping someone here on Stack Overflow can spot the problem..
I am not new coding but am new to JS

–Richard

I expected the amount of transaction to show as 35.00

Asynchroneous execution within Playwright test

I have a test which aims to check whether the contents downloaded from a page match the expected content. My code:


const expectedFiles = [...]
let actualFiles = [];

fs.createReadStream('/tmp/mydrivecontents.zip')
    .pipe(unzipper.Parse())
    .on('entry', function (entry) {
      var fileName = entry.path;
      actualFiles.push(fileName)
    });
  

if (actualFiles == expectedFiles) {
  await page.evaluate(_ => {}, `browserstack_executor: ${JSON.stringify({action: 'setSessionStatus',arguments: {name: 'can download drive contents', status: 'passed',reason: 'Can download drive contents'}})}`);
} else {
  await page.evaluate(_ => {}, `browserstack_executor: ${JSON.stringify({action: 'setSessionStatus',arguments: {name: 'can download drive contents', status: 'failed',reason: 'Can't download drive contents'}})}`);
}

It used to work correctly. However running it now it always fails because it executes the if/else block before the fs.createReadStream() function. I tried to make sure the conditional block executes last by using callback functions, but this produces a Playwright error saying “reserved word: await” and reports that no tests were found, since I don’t think Playwright allows to have await statements inside a function inside a test.

Any ideas how to go about this? Everything online related to sequential execution in Playwright is about the sequence of multiple tests, not of function execution within a test.

Error delivering message to node:undefined [undefined]

After updating a flows in my Node-RED project by re-importing them, I encountered the following error:

12 Feb 13:42:43 - [error] Error delivering message to node:undefined [undefined]
12 Feb 13:42:43 - [error] TypeError: sendEvent.destination.node.receive is not a function
at deliverMessageToDestination (C:[email protected]:799:40)
at Immediate._onImmediate (C:[email protected]:815:21)
at processImmediate (node:internal/timers:476:21)

I couldn’t find any documentation on this error, and it’s proving difficult to understand what’s happening. Any insights or suggestions would be greatly appreciated.