Fail to fetch javascript dynamic URL search input

Why I’m having the Fail to Fetch error in the code while searching the dynamic url endpoint ? The syntacsic is correct I think.
https://codesandbox.io/s/onscroll-izfjoc?file=/index.html:1906-2125

// html
<input
            type="text"
            class="input font--m1"
            placeholder="Search for the item"
            x-model="search"
            @keyup.enter="$store.products.getAllProducts(search)"
          />
          
// script js         
people: [],
getAllProducts(searchInput) {
    let searchUrl = searchInput;
    fetch(`http://test.mosvesna.ru/?search=${searchUrl}`)
      .then((response) => response.json())
      .then((res) => {
        let local = this;
          this.people = res;
      });
    }

VueJS @google-cloud/logging-winston (intermediate value).GoogleAuth is not a constructor

I am trying to add @google-cloud/logging-winston to my VueJS project. I followed these https://www.npmjs.com/package/@google-cloud/logging-winston and https://cloud.google.com/logging/docs/samples/logging-winston-quickstart very closely.

I am getting:

TypeError: (intermediate value) (intermediate value) (intermediate value).GoogleAuth is not a constructor
     at new Logging(index.js ? 221c: 137: 1)
     at new LoggingCommon(common.js ? bc26 : 94: 1)
     at new LoggingWinston(index.js ? 1856 : 113: 1)

Here’s my code:

const winston = require('winston');

const {LoggingWinston} = require('@google-cloud/logging-winston');

// error here
const gcloudWinston = new LoggingWinston();

I don’t understand how the imported constructor would throw a TypeError (for another constructor of GoogleAuth).

Trigger key functionality works, but fails the test

I am doing the drum machine assignment on freecodecamp. In the their test suite, they ask to assign a specific key to a specific drum sound. It works as they ask (or so I think) but it fails the test.

For example: When I press Q on my keyboard, it should play the “heater-1” sound, which it does. But it fails the test.

Here’s my code snippet:

  window.addEventListener("keydown", (e) => {
    if (["q", "w", "e", "a", "s", "d", "z", "x", "c"].includes(e.key)) {
      // debugger;
      for (const obj of drumSounds) {
        if (obj.keyLabel === e.key.toUpperCase()) {
          let button = document.getElementById(obj.id);
          button.click();
          setTextToDisplay(obj.keyLabel);
          return;
        }
      }
    }
  });

  return (
    <div id="drum-machine" className="App">
      <Display displayText={textToDisplay} />
      <div id="drum-pad-container">
        {drumSounds.map((obj) => (
          <DrumPad
            audioSource={obj.src}
            audioId={obj.keyLabel}
            key={obj.keyLabel}
            drumPadId={obj.id}
            keyLabel={obj.keyLabel}
            onClick={(e) => {
              e.target.children[0].play();
              setTextToDisplay(obj.keyLabel);
            }}
          />
        ))}
      </div>
    </div>
  );
}

Why is my info not being pushed into array

I am trying to fetch a img url from an api and then push it into arr, but, arr will only contain one element every iteration when it is supposed to have 3 at the end. I want the array to have 3 img urls at the end of the loop.

let arr = [];
const cats = [1, 2, 3]
const generateCat = () => {
  fetch(
      "https://api.thecatapi.com/v1/images/search?size=small&limit=1&mime_types=jpg,png&width=200&height=200"
    )
    .then(response => {
      return response.json()
    })
    .then(data => {
      for (let i = 0; i < cats.length; i++) {
        arr.push(data[0]['url']);
        console.log("Images Array: " + arr);
      }

    })
};
generateCat()

How can I manipulate textContent of a p element from inside a for-loop?

I am trying to add textContent of a p element from inside a for-loop :

const ls = [1, 2, 3, 4, 5, 6]
const p = document.createElement('p')
p.classList.add('text-body-secondary')
for (let i = 0; i > ls.length; i++) {
  p.textContent += 'abc'
  // p.textContent = 'abc'   // Does not work either.
  if (i !== ls.length - 1) {
    p.textContent += ', '
  }
}
console.log(p)

expecting :

<p class="text-body-secondary">abc, abc, abc, abc, abc, abc</p>

But it did not work.

Here are what I have tried:

  • I have changed const to let.
  • p.textContent = 'abc'
  • no forEach or map since I need to use index.

Is this not allowed to manipulate p.textContent from inside a for-loop?

How can I achieve this?

Check whether at-least one digital signature is present in PDF

I am trying to build an SAP iRPA automation where invoices are read with help of OCR and processed in SAP S4 system.
One validation criteria is the invoice should contain at-least one digital signature. If no digital signature is present invoice has to be rejected.

SAP iRPA tool have JavaScript language at the base and custom JavaScript code can be written.
Can someone help with how to perform the check.

If any API’s are there then please mention those also.

Tried exploring different api’s and they do not have this functionality.
eg docusign can verify pdf that has been signed from the docusign service only.

MultiSelect Tag how to enter only 1 item

I use MultiSelect Tag , please tell me how to make it possible to select only 1 item and block the select.
And another question is how to pass a value to the select via js
Thanks a lot

if (document.querySelector('.select')){
    new MultiSelectTag('country')
}

convert XML to PDF Suitelet without making advance PDF tempelate

I created button to download XML (excel) ExcelStr and downloaded fine

 ExcelStr += '</Table></Worksheet></Workbook>';


               
                var strXmlEncoded = encode.convert({
                    string: ExcelStr,
                    inputEncoding: encode.Encoding.UTF_8,
                    outputEncoding: encode.Encoding.BASE_64
                });

                var objXlsFile = file.create({
                    name: 'Report Summary Item Receipt' + ' from ' + start + ' to ' + end + '.xls',
                    fileType: file.Type.EXCEL,
                    contents: strXmlEncoded

                });

                context.response.writeFile({
                    file: objXlsFile
                });

and i want to make an button to download the pdf version. how do i convert my xml file into pdf withourt having to create and import data into advenced pdf tempelate?

How to protect or add authentication over a Lambda Function returning HTML Page

I have an application using A REST API Gateway in AWS. That API has a few resources, two of them are as follows

  1. {{API_URL}}/{{API_STAGE}}/show-data (GET Method) – This endpoint triggers a lambda function that returns an index.html containing jQuery Datatable which then calls the get-data endpoint through POST Method using AJAX.
  2. {{API_URL}}/{{API_STAGE}}/get-data (POST Method) – This endpoint triggers a lambda, gets some information from S3 bucket and then sends the JSON response.

A brief about my implementation.

Following this tutorial I created a Token Based Lambda Authorizer and added it to get-data endpoint in the REST API. This restricts anyone who doesn’t have the Bearer Token to access this endpoint. Therefore making it private.

Next in show-data endpoint using AJAX I am calling the get-data endpoint. When this request is made, anyone can inspect the page, go to the Networks Tab and see all the Request Headers which also includes the sent Token in Authorization Header. Not just that, if anyone checks the source of the page, they will be able to see the code/token added as a header in Ajax Configuration.

So I am stuck trying to make the show-data endpoint secure.

Code of Lambda Function Triggered through show-data

index.js

const fs = require('fs');
const html = fs.readFileSync('index.html', { encoding:'utf8' });

const generateHTMLTable = async () => {
    
    const table = `<table id="reportTable" class="display"><thead><tr>{thead}</tr></thead><tbody>{tbody}</tbody><tfoot>{tfoot}</tfoot></table>`;
    const thead = `<th>S.No</th><th>Code</th><th>Name</th><th>Status</th><th>Date</th>`;
    let tbody = "";

    return table.replace("{thead}", thead).replace("{tbody}", tbody).replace("{tfoot}", thead);
}

module.exports.showData = async () => {
    const reportTable = await generateHTMLTable();
    
    const modifiedHTML = html.replace("{table}", reportTable);
    
    return {
        statusCode: 200,
        headers: {
            'Content-Type': 'text/html',
        },
        body: modifiedHTML
    }
}

index.html (ajax code)

var table = $('#reportTable').DataTable(
  {
    processing: true,
    serverSide: true,
    serverMethod: 'POST',
    dataType: 'json',
      ajax: {
        url: 'get-data',
        dataSrc: 'data',
        dataType: 'JSON',
        data: function(d){
          return JSON.stringify(d);
        },
        headers: {
        "Accept" : "application/json",
        "Content-Type": "text/json; charset=utf-8",
        // Here is the Authorization Token Passed which can be seen if someone sees the source.
        "Authorization":"Bearer **********************",
        }
      },
      dom: 'Bfrtip',
      select: true,
  }
);

Image Showing Exposed Bearer Token During API Call to get-data

Problem in Hand

How do I make the show-data lambda secure?

How to override CSS in apostrophe-cms pro in TheAposPallete.vue

I’m new to apostrophe-pro and in node_modules I can see a file TheAposPallete.vue which can be located at

node_modules@apostrophecms-propaletteuiaposcomponents

This file has following CSS:

  .apos-palette__grouped.is-open .apos-palette__grouped__schema {
      max-height: 100vh;
   }

I want to override this since this is causing some issues. I tried overriding this in index.scss through important flag. But that didn’t work.

Is there a way we can override this or is this even overridable?

Sending Uploaded Files Using HTML Form Through Javascript to API [duplicate]

How can i sending uploaded files using HTML form through Javascript to API? Below was the sample code. I’m using web-to-lead method by EspoCRM.

<div id="web-to-lead-form-container">
    <form id="web-to-lead-form">
        <div>
            <input type="text" name="firstName" placeholder="First Name">
        </div>
        <div>
            <input type="text" name="lastName" placeholder="Last Name" required>
        </div>
        <div>
            <input type="email" name="emailAddress" placeholder="Email Address" required>
        </div>
        <div>
            <input type="file" name="firstDocument">
        </div>
        <div>
            <input type="file" name="secondDocument">
        </div>
        <div>
            <button type="submit" name="submit">Submit</button>
        </div>
    </form>
</div>

<script type="text/javascript">
    let webToLeadFormElement = document.getElementById('web-to-lead-form');
    let webToLeadFormIsSubmitted = false;

    webToLeadFormElement.addEventListener('submit', event => {
        event.preventDefault();

        if (webToLeadFormIsSubmitted) {
            return;
        }

        webToLeadFormIsSubmitted = true;
        webToLeadFormElement.submit.setAttribute('disabled', 'disabled');

        let payloadData = {
            firstName: webToLeadFormElement.firstName.value || null,
            lastName: webToLeadFormElement.lastName.value || null,
            emailAddress: webToLeadFormElement.emailAddress.value || null,
        };

        // A needed URL can be found on the Lead Capture detail view.
        let url = 'https://URL_OF_YOUR_CRM/api/v1/LeadCapture/API_KEY';

        let xhr = new XMLHttpRequest();

        xhr.open('POST', url, true);

        xhr.setRequestHeader('Content-Type', 'application/json');
        xhr.setRequestHeader('Accept', 'application/json');

        xhr.onreadystatechange = () => {
            if (this.readyState == XMLHttpRequest.DONE && this.status == 200) {
                let containerElement = document.getElementById('web-to-lead-form-container');

                containerElement.innerHTML = 'Sent';
            }
        };

        xhr.onerror = () => {
            webToLeadFormElement.submit.removeAttribute('disabled');
            webToLeadFormIsSubmitted = false;
        };

        xhr.send(JSON.stringify(payloadData));
    });
</script>

I try to put firstDocument: webToLeadFormElement.firstDocument.value || null, on letpayloadData but nothing happen. I know its wrong because im still new on javascript.

How do i link where my node program lives

#!/usr/lib/libSystem.B.dylib is the link where my node program lives and I am able to run my programs with this link. anyone has any idea how I can move or link this to /usr/bin/node since that is the link given in my project?

Meanwhile, I have already tried linking the two locations using: ln -s /usr/lib/libSystem.B.dylib /usr/bin/node and this did not work. I was hoping I can link it like this. I also tried to move it and it did not work either.