Javascript isn’t able to pull some paths from aws api gateway

I am trying to create a login system on my website. I’m using Lambda, api gateway, and dynamodb(but I don’t think that the database matters for this problem).
this is what I see on Api gateway.
Here is my code:

    const healthPath = '/health';
    const registerPath = '/register';
    const loginPath = '/login';
    const verifyPath = '/verify';
    // initiallized all of the things to check

    const registerService = require('./service/register');
    const loginService = require('./service/login');
    const verifyService = require('./service/verify');
    const util = require('./utils/util');//this is for a common return function we can use from file     to file
    // connecting to other codes for giving each item a seperate function

    exports.handler = async(event) => { 
        console.log(event.httpMethod , event.path)
        console.log('Request Event: ', event);
        let response;
        switch(true){ // Checking if it is a get or post method This is a giant if statement
            case event.httpMethod === 'GET' && event.path === healthPath:
                response = util.buildResponse(200); // 200=sucess so that means everything went well
                break;
          
            case event.httpMethod === 'POST' && event.path === registerPath:
                const registerBody = JSON.parse(event.body);
                response = await registerService.register(registerBody); //register() defined in register.js all the other functions are done the same way in the service folder
                break;
            
            case event.httpMethod === 'POST' && event.path === loginPath:
                console.log("called login function")
                const loginBody = JSON.parse(event.body);
                response = await loginService.login(loginBody);
                break;  
            
            case event.httpMethod === 'POST' && event.path === verifyPath: //this checks if the client's token is valid
                const verifyBody = JSON.parse(event.body);
                response = verifyService.verify(verifyBody);
                break;
        
            default:
                response = util.buildResponse(404, '404 Not Found')
        }
        return response;
    };

So I ran the code and used postman to test for each case. The health path and the register path worked perfectly and I was able to input a new user onto the database. Yet for some reason the login and verify paths lead to the switch fuction using the default output. The cloudwatch console for both cases(login and verify) shows the event.httpMethod and the event.path as undefined if I try calling the login and verify paths but it works for the the health and register path. The fuction return in the output status is in util.js.

Exactly how are JavaScript promise .then() handled in the event loop?

I’m getting confused on how the following testcode would be put into the JS event loop.

var p1 = new Promise(function(resolve, reject) {
  setTimeout(function() {
    resolve(1)
  }, 100)
});
var p2 = new Promise(function(resolve, reject) {
  setTimeout(function() {
    resolve(2)
  }, 0)
});
p1.then((value)=>{console.log(value)})
p2.then((value)=>{console.log(value)})

From my understanding, wouldn’t the setTimeout functions be synchronously called and then right after the two .then events be added into the microtask queue? But wouldn’t this mean that at the end of the current iteration the two microtasks are ran before the resolve functions are even ran? Or is it that when resolve functions are called, all microtasks related to that promise are called at the end of the current iteration?

I think it would be best if somebody could just explain to me step-by-step on how the code is added into the event loop and then ran.

How to block only youtube url that has the word embed in chrome extension App

Am working with Chrome Extension App. The background.js below allows all url from youtube and facebook and its working fine.

What i want is to only block or exclude youtube url that has the word embed while allowing other as per

https://www.youtube.com/embed/video_id

That is, If Youtube url link ever contain the word embed please block or exclude them while allowing other url

Some Stackoverflow Scholars suggest exclusion via js code here but I do not know how exactly to go about with it. Stackoverflow Source

Here is my background.js

chrome.webNavigation.onCompleted.addListener(
  async () => {
    await chrome.action.openPopup();
  },
  { url: [
    { urlMatches: 'https://www.youtube.com/*' },
    { urlMatches: 'https://www.facebook.com/*' },
  ] },
);

manifest.json

{
  "name": "Test Extension",
  "description": "My App Details",
  "version": "1.0",
  "manifest_version": 3,
  "permissions": ["webNavigation"],
  "action": { "default_popup": "popup.html" },
"background": { "service_worker": "background.js" }
}

Upload Azure API HTML page keeps refreshing on form submission instead of uploading

My API provides users with a HTML page to upload files to my Azure Storage container. I have two Azure Functions – one to upload files to the Azure Storage containers and another one to generate SAS tokens for the page to create an upload URL. When I submit the form that contains the file, however, the page is just refreshed, and I am not entirely sure what to do.

Code Snippet:

   

 <form method = "post" enctype="multipart/form-data" id = finalfilesubmit>
        <center><label for = "myfile"><strong>Select a file to be uploaded:</strong></label>
        <input class = choosebutton type = "file" id = "myfile" name = "filename"></center><br>
    <center><input class = uploadbutton type = "submit" onclick="finalSubmission()" value = "Upload File"></form></center>
    
<script>
        async function obtainSASToken () {
            var test = ""; 
            let containerName = document.getElementById("containername").value;  // name of container in azure storage account
            let sasTokenUrl = await fetch("https://<sas-function>/?" + 'cont=' + containerName);
        //... code for getting sas token from fetch 
            test = rawData[3]; // sas token location
            return await test;
        }
        async function assignSas () {
            const tokenFinal = await obtainSASToken();
            return tokenFinal;
        }
        async function finalSubmission () {
            let containerName = document.getElementById("containername").value; // name of container in azure storage account
            let accessKey = await assignSas();
            let urlFinal = "https://<upload-function>/?" + "cont=" + containerName + "&ak" + accessKey;
            document.getElementById("finalfilesubmit").action = urlFinal;
        }
    </script>

I tried changing the submit button to be a regular button as shown here How do I make an HTML button not reload the page however the upload functionality still does not work. preventDefault has not worked either. I was considering changing “finalSubmission” into a sync function, however when I try to obtain the SAS token from the async functions it just returns a promise object.

Canvas not showing some paths

Why are my paths sometimes not showing up when calculated by my internal functions from variables like %?

When developing simple graphic tool to create fillable templates which I can convert to images, I noticed that sometimes my drawn paths were disappearing depending on their positioning. This could be fixed by adding 0.02px or Number.ESPSILON to some points, but this is not really a solution. Why is that happening?

Puppeteer checking proxy returns my original IP address

I wanted to use a proxy in Puppeteer but it only works in normal websites like google or stackoverflow but when I check a website like whatismyipaddress it doesn’t work if I point it directly inside the code but it works if I searched for it but it returns my original IP without the proxy , why is that or is something wrong with my code ?

import puppeteer from "puppeteer-extra";
import Stealth from 'puppeteer-extra-plugin-stealth'
import { executablePath } from "puppeteer";
import useProxy from "puppeteer-page-proxy";

puppeteer.use(Stealth())
async function main(url) {

const proxy = 'http://135.181.40.86:8080';
const browser = await puppeteer.launch({ 
    headless: false, 
    defaultViewport: null , 
    executablePath: executablePath() , 
    args: [`--proxy-server=${proxy}`] 
})

const page = await browser.newPage()
await page.setRequestInterception(true);
await page.goto(url)


await page.waitForTimeout(10000000)
await browser.close()
}

main("https://www.whatismyipaddress.com/")

Why are my Copilot shortcuts not working? (show next / previous suggestion)

I’m having a problem with Copilot shortcuts on Mac.

I’m using a czech keyboard so the default shortcuts for Next / Previous suggestions (option+] / option+[) don’t work (as the key combionation just makes a literal bracket.

Even though I bind it to different key combinations, the shortcuts don’t work. What’s wrong?

(The files below are my settings.json and keybinds.json)
copilot bindings

{
  "security.workspace.trust.startupPrompt": "never",
  "security.workspace.trust.enabled": false,
  "files.autoSave": "afterDelay",
  "files.associations": {
    ".py": "Python",
    "*.sql": "sql",
    "*.js": "javascript",
    "*.css": "css",
  },
  "editor.quickSuggestions": {
    "other": "on",
    "comments": "off",
    "strings": true
  },
  "editor.bracketPairColorization.enabled": true,
  "python.defaultInterpreterPath": "/usr/local/bin/python3.10",
  "workbench.preferredLightColorTheme": "Tomorrow Night Blue",
  "workbench.preferredDarkColorTheme": "Kimbie Dark",
  "zenMode.hideLineNumbers": false,
  "zenMode.centerLayout": false,
  "editor.cursorBlinking": "solid",
  "liveServer.settings.donotShowInfoMsg": true,
  "liveServer.settings.donotVerifyTags": true,
  "editor.fontSize": 16,
  "git.confirmSync": false,
  "git.enableSmartCommit": true,
  "security.workspace.trust.untrustedFiles": "open",
  "gitlens.currentLine.enabled": false,
  "gitlens.hovers.currentLine.over": "line",
  "vsicons.dontShowNewVersionMessage": true,
  "terminal.integrated.defaultProfile.windows": "Git Bash",
  "[4GL]": {
    "files.encoding": "iso88592"
  },
  "[plaintext]": {
    "editor.suggest.showWords": true
  },
  "reactSnippets.settings.prettierEnabled": true,
  "emmet.includeLanguages": {
    "javascript": "javascriptreact"
  },
  "[sql]": {},
  "workbench.colorTheme": "Atom One Dark",
  "workbench.iconTheme": "vscode-icons",
  "workbench.startupEditor": "none",
  "editor.linkedEditing": true,
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  "[javascriptreact]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[css]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[javascript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[typescriptreact]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[typescript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[svelte]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[python]": {
    "editor.defaultFormatter": "ms-python.python",
    "editor.formatOnType": true
  },
  "[jsonc]": {
    "editor.defaultFormatter": "vscode.json-language-features"
  },
  "editor.tabSize": 2,
  "[java]": {
    "editor.defaultFormatter": "redhat.java"
  },
  "typescript.updateImportsOnFileMove.enabled": "always",
  "editor.inlineSuggest.enabled": true,
  "github.copilot.enable": {
    "*": true
  },
  "rust-analyzer.checkOnSave.command": "clippy",
  "[rust]": {
    "editor.defaultFormatter": "rust-lang.rust-analyzer",
    "editor.formatOnSave": true
  },
  "bracket-pair-colorizer-2.depreciation-notice": false,
  "[toml]": {
    "editor.defaultFormatter": "tamasfe.even-better-toml"
  },
  "crates.localCargoIndexBranch": "origin/HEAD",
  "crates.useLocalCargoIndex": false,
  "git.openRepositoryInParentFolders": "always",
  "launch": {
    "configurations": [],
    "compounds": []
  },
  "code-runner.customCommand": "cargo run",
  "code-runner.runInTerminal": true,
  "code-runner.saveAllFilesBeforeRun": true,
  "terminal.integrated.env.osx": {
    "FIG_NEW_SESSION": "1"
  },
  "workbench.editorAssociations": {
    "*.md": "vscode.markdown.preview.editor"
  },
  "rust-analyzer.lens.implementations.enable": false,
  "postcssSorting.config": {
    "properties-order": "alphabetical",
  },
  "workbench.sideBar.location": "right",
  "editor.formatOnSave": true,
  "svelte.enable-ts-plugin": true,
}
// Place your key bindings in this file to override the defaultsauto[]
[
  {
    "key": "cmd+r",
    "command": "editor.action.changeAll",
    "when": "editorTextFocus && !editorReadonly"
  },
  {
    "key": "cmd+enter",
    "command": "-editor.action.insertLineAfter",
    "when": "editorTextFocus && !editorReadonly"
  },
  {
    "key": "cmd+l cmd+o",
    "command": "-extension.liveServer.goOnline",
    "when": "editorTextFocus"
  },
  {
    "key": "cmd+[IntlBackslash]",
    "command": "-editor.action.inPlaceReplace.up",
    "when": "editorTextFocus && !editorReadonly"
  },
  {
    "key": "shift+enter",
    "command": "java.debug.runJavaFile"
  },
  {
    "key": "cmd+[BracketLeft]",
    "command": "editor.action.commentLine",
    "when": "editorTextFocus && !editorReadonly"
  },
  {
    "key": "shift+cmd+[BracketLeft]",
    "command": "-editor.action.commentLine",
    "when": "editorTextFocus && !editorReadonly"
  },
  {
    "key": "cmd+i",
    "command": "-interactiveEditor.start",
    "when": "interactiveEditorHasProvider && !editorReadonly"
  },
  {
    "key": "cmd+i",
    "command": "-editor.action.triggerSuggest",
    "when": "editorHasCompletionItemProvider && textInputFocus && !editorReadonly && !suggestWidgetVisible"
  },
  {
    "key": "cmd+i",
    "command": "-focusSuggestion",
    "when": "suggestWidgetVisible && textInputFocus && !suggestWidgetHasFocusedSuggestion"
  },
  {
    "key": "cmd+i",
    "command": "-markdown.extension.editing.toggleItalic",
    "when": "editorTextFocus && !editorReadonly && editorLangId =~ /^markdown$|^rmd$|^quarto$/"
  },
  {
    "key": "cmd+i",
    "command": "-toggleSuggestionDetails",
    "when": "suggestWidgetHasFocusedSuggestion && suggestWidgetVisible && textInputFocus"
  },
  {
    "key": "cmd+i",
    "command": "editor.action.quickFix",
    "when": "editorHasCodeActionsProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "cmd+[Period]",
    "command": "-editor.action.quickFix",
    "when": "editorHasCodeActionsProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "cmd+enter",
    "command": "-notebook.cell.insertCodeCellBelow",
    "when": "notebookCellListFocused && !inputFocus"
  },
  {
    "key": "cmd+enter",
    "command": "-search.action.openInEditor",
    "when": "hasSearchResult && searchViewletFocus"
  },
  {
    "key": "ctrl+f5",
    "command": "-workbench.action.debug.run",
    "when": "debuggersAvailable && debugState != 'initializing'"
  },
  {
    "key": "f5",
    "command": "-workbench.action.debug.start",
    "when": "debuggersAvailable && debugState == 'inactive'"
  },
  {
    "key": "cmd+enter",
    "command": "code-runner.runCustomCommand"
  },
  {
    "key": "ctrl+alt+k",
    "command": "-code-runner.runCustomCommand"
  },
  {
    "key": "cmd+[IntlBackslash]",
    "command": "workbench.action.togglePanel"
  },
  {
    "key": "cmd+j",
    "command": "-workbench.action.togglePanel"
  },
  {
    "key": "cmd+o cmd+p",
    "command": "markdown.showPreviewToSide",
    "when": "!notebookEditorFocused && editorLangId == 'markdown'"
  },
  {
    "key": "cmd+k v",
    "command": "-markdown.showPreviewToSide",
    "when": "!notebookEditorFocused && editorLangId == 'markdown'"
  },
  {
    "key": "cmd+k cmd+c",
    "command": "-editor.action.addCommentLine",
    "when": "editorTextFocus && !editorReadonly"
  },
  {
    "key": "cmd+k cmd+c",
    "command": "-notebook.cell.collapseCellInput",
    "when": "notebookCellListFocused && !inputFocus && !notebookCellInputIsCollapsed"
  },
  {
    "key": "cmd+k cmd+c",
    "command": "-notebook.cell.expandCellInput",
    "when": "notebookCellInputIsCollapsed && notebookCellListFocused"
  },
  {
    "key": "cmd+k cmd+c",
    "command": "github.copilot.toggleCopilot"
  },
  {
    "key": "alt+cmd+down",
    "command": "workbench.action.nextSideBarView"
  },
  {
    "key": "alt+cmd+up",
    "command": "workbench.action.previousSideBarView"
  },
  {
    "key": "alt+cmd+up",
    "command": "-workbench.action.terminal.focusPreviousPane",
    "when": "terminalFocus && terminalHasBeenCreated || terminalFocus && terminalProcessSupported"
  },
  {
    "key": "alt+cmd+up",
    "command": "-editor.action.insertCursorAbove",
    "when": "editorTextFocus"
  },
  {
    "key": "alt+cmd+down",
    "command": "-editor.action.insertCursorBelow",
    "when": "editorTextFocus"
  },
  {
    "key": "alt+cmd+down",
    "command": "-workbench.action.terminal.focusNextPane",
    "when": "terminalFocus && terminalHasBeenCreated || terminalFocus && terminalProcessSupported"
  },
  {
    "key": "cmd+s",
    "command": "extension.multiCommand.execute",
    "args": {
      "sequence": [
        "postcssSorting.execute",
        "workbench.action.files.save"
      ]
    },
    "when": "editorLangId == css"
  },
  {
    "key": "shift+cmd+[Period]",
    "command": "-breadcrumbs.focus",
    "when": "breadcrumbsPossible && breadcrumbsVisible"
  },
  {
    "key": "ctrl+[BracketRight]",
    "command": "github.copilot.nextPanelSolution"
  },
  {
    "key": "ctrl+[BracketLeft]",
    "command": "github.copilot.previousPanelSolution"
  },
  // {
  //   "key": "ctrl+[BracketRight]",
  //   "command": "editor.action.inlineSuggest.showNext",
  //   "when": "editorTextFocus && suggestWidgetMultipleSuggestions && suggestWidgetVisible"
  // },
  // {
  //   "key": "ctrl+[BracketLeft]",
  //   "command": "editor.action.inlineSuggest.showPrevious",
  //   "when": "editorTextFocus && suggestWidgetMultipleSuggestions && suggestWidgetVisible"
  // }
]

How can I set values from the constructor of the parent class?

I need to create a generic class that is able to dynamically set values based on the properties of the child class. Here are examples:

export class EnderecoMobile extends ModelCore{

  id: string = ''
  cep: number = 1

  constructor(data){
    super(data)
  }
}

export class ComandadasMobile extends ModelCore {
  postId: number = 1
  id: number = 1
  name: string = ""

  constructor(data){
    super(data)
  }
}

so far i have developed the following code

export class ModelCore {

  constructor(data: any, canal?: string) {
    const device: RegExp = new RegExp(this.getDevice(), 'i');
    let string = this.constructor.toString().replace(/(n|r)/g, '');

    if (device.test(this.constructor.name)) {
        this.montaResposta(data, string)
    }
  }
  /**
   *
   * @returns retorna uma string com o tipo de dispositivo caso a classe seja criada espcificamente para mobile ou desktop.
   * Caso não seja identificado nenhuma das duas opções retorna null
   */
  private getDevice() {
    const regex = /(mobile|desktop)/i;
    const device = this.constructor.name.match(regex);
    return device ? device[0] : undefined;
  }

  private montaResposta(data: any, string: string) {
    Object.keys(data).forEach(key => {
      if (typeof data[key] === 'object') this[key] = this.preencherObjeto(data[key], string);
      if (Array.isArray(data[key])) this[key] = this.preencherArray(data[key], string);
      else
        this.setaVariavel(data, key, string);
    });
  }

  private preencherArray(data: any, string: string): any {
    Object.keys(data).forEach(element => {
      if (typeof data[element] === 'object') {
        this.preencherObjeto(data[element], string);
      } else {
        if (Array.isArray(data[element])) { this.preencherArray(data[element], string) }
        else {
          let key = Object.keys(data[element])[0]; // Corrigido aqui
          this.setaVariavel(data[element], key, string);
        }
      }
    })
  }

  private preencherObjeto(obj: any, string: string) {
    return Object.keys(obj).forEach(key => {
      this.setaVariavel(obj, key, string);
    })
  }

  private setaVariavel(data: any, key: any, string: string) {
    const js: RegExp = new RegExp(` this.${key} `);
    if (this.hasOwnProperty(key) || js.test(string)) { this[key] = data[key]; } else { delete data[key] }
  }
}

if I pass an object in the EnderecoMobile class like: { id: ‘2’, cep: 57057102, number: ‘278’ } the expected result is { id: ‘2’, cep: 57057102 } but the final result is { “id”: “”, “cep”: 1 }

however if I pass an array in the ComandadasMobile class like: [
{
“postId”: 1,
“id”: 1,
“name”: “id labore ex et quam laborum”,
“email”: “[email protected]”,
“body”: “laudantium enim quasi est quidem magnam voluptate ipsam eosntempora quo necessitatibusndolor quam autem quasinreiciendis et nam sapiente accusantium”
},
{
“postId”: 1,
“id”: 2,
“name”: “quo vero reiciendis velit similique earum”,
“email”: “[email protected]”,
“body”: “est natus enim nihil est dolore omnis voluptatem numquamnet omnis occaecati quod ullam atnvoluptatem error expedita pariaturnnihil sint nostrum voluptatem reiciendis et”
},
{
“postId”: 1,
“id”: 3,
“name”: “odio adipisci rerum aut animi”,
“email”: “[email protected]”,
“body”: “quia molestiae reprehenderit quasi aspernaturnaut expedita occaecati aliquam eveniet laudantiumnomnis quibusdam delectus saepe quia accusamus maiores nam estncum et ducimus et vero voluptates excepturi deleniti ratione”
},
]
the final result is:
{
“0”: {
“postId”: 1,
“id”: 1,
“name”: “id labore ex et quam laborum”
},
“1”: {
“postId”: 1,
“id”: 2,
“name”: “quo vero reiciendis velit similique earum”
},
“2”: {
“postId”: 1,
“id”: 3,
“name”: “odio adipisci rerum aut animi”
},
}

I’ve done several experiments and I haven’t found any solution, can anyone help me? =/

I need to create a global class so that developers of other projects can inherit these characteristics and not worry about the return when calling services, because only the properties created in the child class will be returned.

TypeError: Cannot read property ‘BOTTOM’ of undefined

Hello can you help me with this error?

[ERROR] TiExceptionHandler: (main) [340,3234] /ui/common/ApplicationTabGroup_Andr.js:1703
[ERROR] TiExceptionHandler:               MainWallTable.insertRowBefore([0, PendingUploadView, Titanium.UI.RowAnimationStyle.BOTTOM]);
[ERROR] TiExceptionHandler:                                                                                                  ^
[ERROR] TiExceptionHandler: TypeError: Cannot read property 'BOTTOM' of undefined

Thi is my code

        WallsArray.MainWall = WallsArray.MainWall.concat(PendingArrayView);
            MainWallTable.insertRowBefore([0,PendingUploadView,Titanium.UI.iOS.insertRowBefore.BOTTOM])

Titanium version 11.1.1

How to shorten my JS code about popup windows for each button?

How to sum up this code

Hi guys, i am trying to open a popup window when i click on a button. But when i click on button1 it should open window1 and when i click on button2 it should open window2.

The only way i managed to do this is following:

let popup1 = document.getElementById("popup-1");

function openPopup1() {
    popup1.classList.add("open-popup");
    overlay.classList.add("overlay");
}

function closePopup1() {
    popup1.classList.remove("open-popup");
    overlay.classList.remove("overlay");
}


let popup2 = document.getElementById("popup-2");

function openPopup2() {
    popup2.classList.add("open-popup");
    overlay.classList.add("overlay");
}

function closePopup2() {
    popup2.classList.remove("open-popup");
    overlay.classList.remove("overlay");
}

But thats not what i actually want cause its just repeting code. And if i would add another button3 with window3 theres the same thing again. Any ideas how to shorten it so that i dont have double code?

Thanks a lot.

how to make a constructor function from an array

I just started learning programming and I’m stuck on a task. It is necessary to create a JavaScript program that reads the content of the file with data about students and creates Student objects based on such data. After creating a series of Student objects, it is necessary to display data about read students within the page. To create student objects, it is necessary to use the template, constructor function, created in the previous assignment. Thus, this assignment represents an upgrade of the previous one. The only way I succeeded was this way, and this is not good. Can someone help me do this in a better way? Thank you in advance.

 <div id="student1"></div>
 <div id="student2"></div>
 <div id="student3"></div>
 <div id="student4"></div>

 <script>

     function Student(name, address, phone, course) {
         this.name = name;
         this.address = address;
         this.phone = phone;
         this.course = course;

         this.getInfo = function () {
             return 'Name: ' + this.name + 'n' +
                 'Address: ' + this.address + 'n' +
                 'Phone: ' + this.phone + 'n' +
                 'Course: ' + this.course
         };
     };

     async function getData() {
         try {
             let result = await fetch('https://v-dresevic.github.io/Advanced-JavaScript-Programming/data/students.txt');
             let text = await result.text();
             let split = text.split(/n/);

             txt = [];
             for (let i = 0; i < split.length; i++) {
                 txt += split[i];
             };
             const entries = Object.entries(txt);
            

let student1 = new Student(split[0] + ‘
‘, split[1] + ‘
‘, split[2] + ‘
‘, split[3]);
let student1Name = student1.getInfo();
document.getElementById(‘student1’).innerHTML =student1Name;

let student2 = new Student(split[4] + ‘
‘, split[5] + ‘
‘, split[6] + ‘
‘, split[7]);
let student2Name = student2.getInfo();
document.getElementById(‘student2’).innerHTML =student2Name;

let student3 = new Student(split[8] + ‘
‘, split[9] + ‘
‘, split[10] + ‘
‘, split[11]);
let student3Name = student3.getInfo();
document.getElementById(‘student3’).innerHTML =student3Name;

let student4 = new Student(split[12] + ‘
‘, split[13] + ‘
‘, split[14] + ‘
‘, split[15]);
let student4Name = student4.getInfo();
document.getElementById(‘student4’).innerHTML =student4Name;

         }
         catch (err) {
             document.getElementById("full").innerHTML = err.message;
         };

     };

     getData()

     /* let student1 = new Student();
       let student1Name = student1.getInfo();
       console.log(student1Name);*/

 </script>

promise chaining not working as expect in the below code

export async function getOTP(queryParams) {
  return Api.get(getOTPUrl, { params: queryParams })
    .then(response => {
      return response;
    })
    .catch(error => {
      console.log(error);
    });
}


getOTP({ phoneNumber: values.mobileNo })
        .then(res => {
          debugger;
          if (res.data.status == "OK") {
            setTimeout(() => {
              messageApi.open({
                key,
                type: "success",
                content: "OTP Sent!",
                duration: 2,
              });
              setOtpActive(true);
            }, 1000);
          }
        })
        .catch(error => {
          debugger;
        });

In the above code where the getOTP function is being called the program is going inside b “.then” and “.catch” as well when the promise fails. When the promise fails it goes to the first “.catch” in the getOtp function declaration after that it goes to the “.then” block where the getOtp function is being called which was expected behavior as I’m not explicitly throwing promise rejection in the first “.catch” in “getOtp” function declaration but the problem is it is going inside “.cath” as well where the function is being used.

Similar to the above code with some updation for testing the below code is not going inside the last catch:

export async function getOTP(queryParams) {
  return Api.get(getOTPUrl, { params: queryParams })
    .then(response => {
      return response;
    })
    .catch(error => {
      console.log(error);
    })
    .then(res => {
      debugger;
      if (res.data.status == "OK") {
        setTimeout(() => {
          messageApi.open({
            key,
            type: "success",
            content: "OTP Sent!",
            duration: 2,
          });
          setOtpActive(true);
        }, 1000);
      }
    })
    .catch(error => {
      debugger;
    });
}``` 


How to stop crawling the admin with strapi and nuxt

I have a project created with strapi and nuxt. When i try to block the link admin.mywebsite.com from being crawled in the live version with the robots.txt, it doesn’t work. I tried to disallow the /admin, but that didn’t work. It would be possible to block the strapi admin page on the live website? thank you for your help

User-agent: *
Disallow: /admin