Integrating API with WordPress

I’ve been working on this for months now and have talked with my host, the company etc and I can make my api call work on their developer page which has example code to test their API but for the life of me I cannot get it to work on my WordPress site and it is very much needed.

My initial code is as follows:

const options = {
  method: 'POST',
  headers: {
    Accept: '*/*',
    'Content-Type': 'application/json',
    Authorization: 'Basic XXXXXXXREDACTEDXXXXX'
  },
  body: JSON.stringify({firstName: 'John', lastName: 'Doe', phoneNumber: '5444455555'})
};

fetch('https://a.eztexting.com/v1/contacts', options)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));

The first error I receive is:
Access to fetch at ‘https://a.eztexting.com/v1/contacts’ from origin ‘https://businessofimagination.com’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. If an opaque response serves your needs, set the request’s mode to ‘no-cors’ to fetch the resource with CORS disabled.

after trying many different headers all over WordPress and my theme I finally included:
“mode: ‘no-cors’,” into my code

updated code is as follows:

const options = {
  method: 'POST',
  mode: 'no-cors',
  headers: {
    Accept: '*/*',
    'Content-Type': 'application/json',
    Authorization: 'Basic XXXXXXREDACTEDXXXXXX'
  },
  body: JSON.stringify({firstName: 'John', lastName: 'Doe', phoneNumber: '5444455555'})
};

fetch('https://a.eztexting.com/v1/contacts', options)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));

Now the errors I receive are:
POST https://a.eztexting.com/v1/contacts 403 (403 forbidden)
and
SyntaxError: Unexpected end of input

I don’t understand why it refuses to work, or what in WordPress is preventing this. Please any help would be incredible. This has been an incredibly frustrating journey for something that in theory should work fairly seamlessly.

Which is a better Javascript coding practice?

It’s a general question about using let vs const in some situations, to give an example, I have a function that renders a scene on a render target for WebGL with a possible need to set the viewport as well. So is it better to write

const f = (r, v) => {
 const vo = new viewport();
 if(v) {
   r.getViewport(vo);
   r.setViewport(v);
 }
 // render scene
 if(v) r.setViewport(vo);
}

or

const f = (r, v) => {
 let vo; 
 if(v) {
   vo = new viewport();
   r.getViewport(vo);
   r.setViewport(v);
 }
 // render scene
 if(v) r.setViewport(vo);
}

Why is the display value stuck on ‘none’?

In my code, I am looping through a node list that selects the right link, when the node list is clicked. (The links are basically buttons that show and hide text under them when clicked)

(the node list = footerLink
and the text that is shown when one of the links are clicked = linkContent

footerPlus = plus icon shown when link has not been clicked
and footerMinus = minus icon shown when link has been clicked)

The problem is that after I set footerMinus to display = none as its initial state when the page is loaded, when I clicked on the node list, nothing happened. It did not respond. I checked by inspecting it and it turns out that even after I clicked it display remained as none. However, when I removed the initial display = 'none' the text was actually shown after clicking the link. But I cannot leave it like this because the footerMinus is meant to be hidden while the link has not been clicked.

Is there another way of completely hiding the icon without the code being stuck on display = 'none'?

It does not fully work properly as well. For example, the links are under each other and when one is clicked, it actually changes the icon of the one under it instead of its own. I think it has to do with the value of i in the loops. Maybe I should make it i + 1 instead. Clicking the first link changes the first as well as the second icon. The rest of them change the one directly under them, except from the last one which does not change anything.

The JavaScript:

const footerLink = document.querySelectorAll('.footer-link')
const linkContent = document.querySelectorAll('.link-content')
const footerPlus = document.querySelectorAll('.footer-plus')
const footerMinus = document.querySelectorAll('.footer-minus')

// footer

for (i = 0; i < linkContent.length; ++i) {
    linkContent[i].style.display = 'none'
    footerMinus[i].style.display = 'none' // The line that changes everything
}

function footerClick(content) {
    if (content.style.display == 'none') {
        content.style.display = 'block'
    } else {
        content.style.display = 'none'
    }
}


footerLink.forEach(function (link) {
    link.addEventListener('click', function (e) {
        const which = e.currentTarget.classList
        if (which.contains('help')) {
            for (i = 0; i < linkContent.length; ++i) {
                let content = linkContent[i]
                if (linkContent[i].classList.contains('help')) {
                    footerClick(content)

                    if (linkContent[i].style.display == 'none') {
                        footerMinus[i].style.display = 'grid'
                        footerPlus[i].style.display = 'grid'
                    } else {
                        footerMinus[i].style.display = 'grid'
                        footerPlus[i].style.display = 'none'
                    }
                }
            }
        }
        if (which.contains('careers')) {
            for (i = 0; i < linkContent.length; ++i) {
                let content = linkContent[i]
                if (linkContent[i].classList.contains('careers')) {
                    footerClick(content)
                    if (linkContent[i].style.display == 'none') {
                        footerMinus[i].style.display = 'none'
                        footerPlus[i].style.display = 'grid'
                    } else {
                        footerMinus[i].style.display = 'grid'
                        footerPlus[i].style.display = 'none'
                    }
                }
            }
        }
        if (which.contains('sites')) {
            for (i = 0; i < linkContent.length; ++i) {
                let content = linkContent[i]
                if (linkContent[i].classList.contains('sites')) {
                    footerClick(content)
                    if (linkContent[i].style.display == 'none') {
                        footerMinus[i].style.display = 'none'
                        footerPlus[i].style.display = 'grid'
                    } else {
                        footerMinus[i].style.display = 'grid'
                        footerPlus[i].style.display = 'none'
                    }
                }
            }
        }
        if (which.contains('newsroom')) {
            for (i = 0; i < linkContent.length; ++i) {
                let content = linkContent[i]
                if (linkContent[i].classList.contains('newsroom')) {
                    footerClick(content)
                    if (linkContent[i].style.display == 'none') {
                        footerMinus[i].style.display = 'none'
                        footerPlus[i].style.display = 'grid'
                    } else {
                        footerMinus[i].style.display = 'grid'
                        footerPlus[i].style.display = 'none'
                    }
                }
            }
        }
        if (which.contains('franchising')) {
            for (i = 0; i < linkContent.length; ++i) {
                let content = linkContent[i]
                if (linkContent[i].classList.contains('franchising')) {
                    footerClick(content)
                    if (linkContent[i].style.display == 'none') {
                        footerMinus[i].style.display = 'none'
                        footerPlus[i].style.display = 'grid'
                    } else {
                        footerMinus[i].style.display = 'grid'
                        footerPlus[i].style.display = 'none'
                    }
                }
            }
        }
    });
})

So how do I get it to actually display the content it is meant to?

And also how do I get it to actually change the icon next to it instead of the one below it?

Wait for API response before return function – ReactJS

I have a function getData() like this:

const getData = () => {
 const lsData = dummyJsonDataForTest;
 if (condition) {
  return lsData;
 }
 // call API here
 apiService
  .getData()
  .then((json) => {
    return json.data; 
  })
  .catch(() => {
    return null;
  })
 return null;
};

I want to return a response from the API call if the condition is false, but seems that the function getData() will return null before the API response.

Is there any way to make it wait for the response before the function return null?

Thank you in advance.

How to display ALT text to my Lightbox gallery?

I am trying to create my own Lightbox Gallery instead of using a plugin. So I found a really simple script online but now I am trying to display the alt text of the image that is shown in the Lightbox as a caption.

I managed to display the alt text of all images in the gallery but obviously only the alt text of the shown image should be displayed, can someone help me as to how I only pick the alt text from the shown image?

Here is my code:

  <div class="lightbox">
    <div class="wrapper">
      <div class="gallery">
        <div class="image">
          <div class="subimage"><img src="images/cardmapr-rDzI7m7sjPE-unsplash.jpg" loading="lazy" sizes="28vw" srcset="images/cardmapr-rDzI7m7sjPE-unsplash-p-500.jpeg 500w, images/cardmapr-rDzI7m7sjPE-unsplash-p-800.jpeg 800w, images/cardmapr-rDzI7m7sjPE-unsplash-p-1080.jpeg 1080w, images/cardmapr-rDzI7m7sjPE-unsplash-p-1600.jpeg 1600w, images/cardmapr-rDzI7m7sjPE-unsplash.jpg 1920w" alt="Caption alt test" class="image_2"></div>
        </div>
        <div class="image">
          <div class="subimage"><img src="images/sergei-a--heLWtuAN3c-unsplash.jpg" loading="lazy" sizes="28vw" srcset="images/sergei-a--heLWtuAN3c-unsplash-p-500.jpeg 500w, images/sergei-a--heLWtuAN3c-unsplash-p-800.jpeg 800w, images/sergei-a--heLWtuAN3c-unsplash-p-1080.jpeg 1080w, images/sergei-a--heLWtuAN3c-unsplash-p-1600.jpeg 1600w, images/sergei-a--heLWtuAN3c-unsplash.jpg 1920w" alt="caption 2" class="image_2"></div>
        </div>
        <div class="image">
          <div class="subimage"><img src="images/good-faces-agency-sKRavSCadwE-unsplash.jpg" loading="lazy" sizes="28vw" srcset="images/good-faces-agency-sKRavSCadwE-unsplash-p-500.jpeg 500w, images/good-faces-agency-sKRavSCadwE-unsplash-p-800.jpeg 800w, images/good-faces-agency-sKRavSCadwE-unsplash-p-1080.jpeg 1080w, images/good-faces-agency-sKRavSCadwE-unsplash-p-1600.jpeg 1600w, images/good-faces-agency-sKRavSCadwE-unsplash.jpg 1920w" alt="" class="image_2"></div>
        </div>
        <div class="image">
          <div class="subimage"><img src="images/Bild_Haarentfernung_Nachher.png" loading="lazy" sizes="28vw" srcset="images/Bild_Haarentfernung_Nachher-p-500.png 500w, images/Bild_Haarentfernung_Nachher.png 536w" alt="caption last" class="image_2"></div>
        </div>
      </div>
    </div>
    <div class="preview-box">
      <div class="image-box">
        <div class="caption2"></div><img src="https://d3e54v103j8qbb.cloudfront.net/plugins/Basic/assets/placeholder.60f9b1840c.svg" loading="lazy" alt="test test" class="image_3">
      </div>
    </div>
    <div class="shadow">
      <div class="icon closebutton"></div>
      <div class="slide prev"></div>
      <div class="slide next"></div>
      <div class="details">
        <div class="title">
          <p class="current-img">Test1</p>
          <div>/</div>
          <p class="total-img">Test2</p>
        </div>
      </div>
    </div>
  </div>

The very last part in this code, is the jquery I am using to display the alt texts:

const gallery  = document.querySelectorAll(".image"),
previewBox = document.querySelector(".preview-box"),
previewImg = previewBox.querySelector("img"),
shadow = document.querySelector(".shadow"),
closeIcon = shadow.querySelector(".icon"),
currentImg = shadow.querySelector(".current-img"),
totalImg = shadow.querySelector(".total-img");
window.onload = ()=>{
    for (let i = 0; i < gallery.length; i++) {
        totalImg.textContent = gallery.length; //passing total img length to totalImg variable
        let newIndex = i; //passing i value to newIndex variable
        let clickedImgIndex; //creating new variable
        gallery[i].onclick = () =>{
            clickedImgIndex = i; //passing cliked image index to created variable (clickedImgIndex)
            function preview(){
                currentImg.textContent = newIndex + 1; //passing current img index to currentImg varible with adding +1
                let imageURL = gallery[newIndex].querySelector("img").src; //getting user clicked img url
                previewImg.src = imageURL; //passing user clicked img url in previewImg src
            }
            preview(); //calling above function
            const prevBtn = document.querySelector(".prev");
            const nextBtn = document.querySelector(".next");
            if(newIndex == 0){ //if index value is equal to 0 then hide prevBtn
                prevBtn.style.display = "none";
            }
            if(newIndex >= gallery.length - 1){ //if index value is greater and equal to gallery length by -1 then hide nextBtn
                nextBtn.style.display = "none";
            }
            prevBtn.onclick = ()=>{
                newIndex--; //decrement index
                if(newIndex == 0){
                    preview();
                    prevBtn.style.display = "none";
                }else{
                    preview();
                    nextBtn.style.display = "block";
                }
            }
            nextBtn.onclick = ()=>{
                newIndex++; //increment index
                if(newIndex >= gallery.length - 1){
                    preview();
                    nextBtn.style.display = "none";
                }else{
                    preview();
                    prevBtn.style.display = "block";
                }
            }
            document.querySelector("body").style.overflow = "hidden";
            previewBox.classList.add("show");
            shadow.style.display = "block";
            closeIcon.onclick = ()=>{
                newIndex = clickedImgIndex; //assigning user first clicked img index to newIndex
                prevBtn.style.display = "block";
                nextBtn.style.display = "block";
                previewBox.classList.remove("show");
                shadow.style.display = "none";
                document.querySelector("body").style.overflow = "scroll";
            }
            $('.shadow').on('click', function(e) {
              if (e.target !== this)
              return;
              newIndex = clickedImgIndex; //assigning user first clicked img index to newIndex
              prevBtn.style.display = "block";
              nextBtn.style.display = "block";
              previewBox.classList.remove("show");
              shadow.style.display = "none";
              document.querySelector("body").style.overflow = "scroll";
            });
        }
    }
}
  $('.gallery').find('img').each(function() {
      var $alt = $(this).attr('alt');
      $('.caption2').append($alt);
    });

Routing to another page doesn`t be show from the first

I have a project made with Angular 12 and the issue is that when I click a link in page 1 to route to page 2, sometimes the middle or the end of the page 2 will be shown at first and I should scroll up to see the start of the page. What is the problem with this? Should I prioritize the loading of items or something?

Google Places Autocomplete is not working on mobile devices in Vue app

Google places autocomplete is a crucial component of my application and when testing on mobile devices in Chrome, the address suggestions are not populating in the dropdown. In the network tab, the AutocompletionService.GetPredictions calls are all 200. How can I fix this? It works perfectly in a desktop view, but mobile or tablet devices, no. I also tried rotating the orientation of the device to no avail. I load the api using
“@gogglemaps/js-api-loader”, https://www.npmjs.com/package/@googlemaps/js-api-loader.
AddressAutocomple.vue

<template>
  <div>
    <h2 class="group-header">
      {{ title }}
    </h2>
    <h4>Address + City</h4>
    <input id="detailedLocation" ref="autocomplete" type="text" />
    <p
      v-if="!isValidAddress"
      class="serviceAreaNotice"
      :class="{ errorMessage: !isValidAddress }"
    >
      Please enter a valid address within our service area
    </p>
<div>
  <p class="message">
    see our<router-link to="/service">service area</router-link>
    </p>
   </div>
  </div>
</template>

<script>
import { mapActions, mapState } from "vuex";
import { Loader } from "@googlemaps/js-api-loader";
import { serviceAreaZipCodes } from "../Selections/selections";
const loader = new Loader({
  apiKey: "AIzaSyBvWBtJ5i..........", //check api key
  version: "weekly",
  libraries: ["places"],
  async: "defer"
});

export default {
  name: "App",
  data() {
  return {
  info: null,
  searchResults: [],
  address: {
    unit: "",
    street: "",
    city: "",
    state: "",
    zip: ""
  },
  title: "Where?"
  };
  },
  computed: {
    ...mapState(["isValidAddress"])
  },
  async mounted() {
   let location;
   const center = { lat: 42.84498856765032, lng: -74.71060855293794 };
   // Create a bounding box with sides ~10km away from the center point
   const defaultBounds = {
      north: center.lat + 0.5,
      south: center.lat - 0.5,
      east: center.lng + 0.5,
      west: center.lng - 0.5
   };
    const input = document.getElementById("detailedLocation");
    const options = {
    types: ["address"],
    bounds: defaultBounds,
    componentRestrictions: { country: "us" },
    fields: [
       "place_id",
       "geometry",
       "name",
       "address_components",
       "formatted_address"
     ]
   };
  loader
  .load()
  .then(google => {
    location = new google.maps.places.Autocomplete(input, options);
    location.addListener(
      "place_changed",
      () => {
        const place = location.getPlace();
        if (!place.geometry || !place.geometry.location) {
          // User entered the name of a Place that was not suggested and
          // pressed the Enter key, or the Place Details request failed.
          window.alert(
            "No details available for input: '" + place.name + "'"
          );
          document.getElementById("detailedLocation").placeholder =
            "Enter a place";
          return;
        } else {
          document.getElementById("detailedLocation").innerHTML =
            place.formatted_address;
        }
        let addressComponents = place.address_components;
        this.addressInServiceArea(addressComponents);
      }
    );
  })
  .catch(error => {
    console.log(error);
    return error;
  });
},

  methods: {
    ...mapActions([
     "updateApt",
     "updateUnit",
     "updateStreet",
     "updateCity",
     "updateState",
     "updateZip",
     "updateIsValidAddress"
    ]),
    // prompts user to allow device location
    locatorInfo() {
      if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(position => {
          console.log(position.coords.latitude, position.coords.longitude);
        });
     }
    },
    displaySuggestions(predictions, status) {
      if (status !== window.google.maps.places.PlacesServiceStatus.OK) {
        this.searchResults = [];
        return;
      }
      this.searchResults = predictions.map(
        prediction => prediction.description
     );
    },
   saveAddressToState(placeObject) {
      let unit = placeObject[0]["short_name"];
      let street = placeObject[1]["short_name"];
      let city = placeObject[2]["short_name"];
      let statehood = placeObject[5]["short_name"];
      let zip = placeObject[7]["short_name"];
      this.updateUnit(unit);
      this.updateStreet(street);
      this.updateCity(city);
      this.updateState(statehood);
      this.updateZip(zip);
    },
    addressInServiceArea(placeObject) {
      console.log(placeObject);
      const zip = placeObject[7]["short_name"];
      let isInServiceArea = serviceAreaZipCodes.includes(zip);
      if (isInServiceArea) {
        this.saveAddressToState(placeObject);
        this.updateIsValidAddress(true);
      } else {
        this.updateIsValidAddress(false);
     }
      // console.log(this.address.zip, isInServiceArea, "line 127");
      return isInServiceArea;
   }
  }
};
</script>

After the user clicks the address, I run a zip code validation check for the service area.

Mobile
mobile

Desktop

desktop

How to load multiple files using jQuery’s get function?

I am trying to load multiple files using jQuery’s get function. A minimal example looks like this:

<!doctype html>
<html>
    <head>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
    </head>
    <body>
        <select name="file-select" id="file-select" multiple>
            <option>http://url.to.file/Test1.txt</option>
            <option>http://url.to.file/Test2.txt</option>
        </select>

        <script>
            $(document).ready(function() {
                $('#file-select').change(function () {
                    let loaded_files_list = new Array();
                    let promise = new Promise(function(myResolve,myReject) {
                        $("#file-select option:selected").each(function () {
                            file_name = $(this).val();
                            $.get($(this).val(), function(response) {
                                data = response;
                                // Do something with data
                                console.log("file select length: "+$("#file-select option:selected").length);
                                loaded_files_list.push(file_name);
                                console.log('loaded files length: '+loaded_files_list.length)
                                if(loaded_files_list.length == $("#file-select option:selected").length) {
                                    console.log('Entered if clause');
                                    myResolve(loaded_files_list);
                                }
                                else {
                                    myReject('List is not complete yet');
                                }
                            });
                        });
                    }); 
                    promise.then(
                        function(value) {
                            console.log('List is complete!');
                            console.log(value);
                        },
                        function(error) {
                            console.log(error);
                        }
                    );  
                }); 
            });


        </script>
    </body>
</html>

Now if I select a single file this works just like expected and I can see the list with a single item in the console. However if I I select both files, the if clause is entered after both files are loaded, but it seems myResolve is not called as neither List is complete! is displayed nor the list with two elements. What am I doing incorrect here?

quickbooks support Phone number 1(844)563-1541 tech support number

quickbooks support Phone number 1(844)563-1541 tech support number QuickBooks helpline number is open for everyone who are seeking help for QuickBooks. You can contact to our certified QuickBooks proadvisors to get resolve all your related issues. As you know the importance of business accounting nowadays. For every business accounting play a important role and as a worlds leading accounting software QuickBooks help you to manage everything in your business accounting and make your accounting easy. so here we are presenting this toll-free QuickBooks phone number 1(844)563-1541 so you can get help in your needed time. Dial our QuickBooks number now to get connected to our QuickBooks customer service phone number.
Services 1(844)563-1541 We offered at Our QuickBooks Customer Service 1(844)563-1541

Our QuickBooks Customer Service 1(844)563-1541 consists of well-trained professionals who are capable of solving all your issues with the help of advanced tools and techniques. QB is sophisticated software and requires expert support to fix its complicated issues.QuickBooks Support Providers have aptitude in innovation and arrangements mix for little to medium measured organizations. We are guaranteed to exchange, execute, and support QuickBooks Desktop Enterprise, QuickBooks Point of Sale, and other QuickBooks and outsider items.
Ensured QuickBooks ProAdvisors have skills in accounting administrations from your little to medium estimated organizations. They are normally CPAs, bookkeepers, and private company counselors or specialists who have been tried and confirmed by Intuit to assist organizations with learning and use QuickBooks. QuickBooks makes it much simpler for little and huge endeavors to manage their bookkeeping needs adequately and productively at every time and spot. With QuickBooks, you can without a doubt keep various business objectives, trades, charge assortment, random expenses, and different consumptions in line.
Over the course of the years, QuickBooks has developed to turn into a necessary piece of all fruitful little and huge organizations all through the world. This accounting programming empowers you to remain associated with your business each second of the day and also requires QuickBooks Customer Support.

QuickBooks Online Support

Knock on our Quickbook Online Help 1(844)563-1541 assistance’s door if you realize that you need some kind of professionals and experts’ help to explore more this well-known accounting tool “Quickbooks”. Undoubtedly, there are tons of advanced tools and software in the market which are being used to do accounting operations, but Quickbooks Online is the only option or way before and after in spite of all other accounting software, businesses from sole proprietor to well-established one can blindly rely on it. Contact our Quickbooks Online support 1(844)563-1541 team to get the valuable answer to your query.

How do I control web page caching, across all browsers?

I have a website up and running; I am constantly working on improving the site. But unless the costumer presse clears the cache it does not update to the latest version of my css and html. I wanted to change the http cache header to be

USING HTML

<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">

So this way the website has all the current info at all time.

But I have no idea as to where to put this code in. Do I create a new file named html or do I just input this somewhere in my index.html. Please help.

change flag retain national number – react phone number input

How do i retain national number when user change flag? If they change flag the numbers they put in previously should be left. setValue doesnt trigger the value field.

function App() {

  const { register, handleSubmit, watch, errors, setValue, control } = useForm();
  const [valueX, setValueX] = useState("");

  useEffect(() => {    
    try{
      sessionStorage.setItem("national", parsePhoneNumber(valueX).nationalNumber)
    }catch(err){}

    try{
      sessionStorage.setItem("countryCode", parsePhoneNumber(valueX).countryCallingCode)
    }catch(err){}
}, [valueX]);


  function test(x){     
    console.log("changed country") 
      console.log(getCountryCallingCode(x))
    setValue("test",x+sessionStorage.getItem("national"))
  }
  
  return (
    <div className="App">     
      <form>    
        <PhoneInput name="test" international value={valueX} onChange={e => setValueX(e)}
        onCountryChange={e => {test(e)}}
        control={control}        
      />   
      </form>    
    </div>
  );
}

export default App;

url.pathToFileURL is not a function : how to convert a file path to an URL in node.js?

I want to convert a file path to an URL.

I tried to follow the indications found in the official docs: https://nodejs.org/dist/latest-v16.x/docs/api/url.html#urlpathtofileurlpath

import { pathToFileURL } from 'url'

let filepathurl = pathToFileURL(file.path)

But I get this error:

Uncaught TypeError: (0 , _url.pathToFileURL) is not a function

Other info:

node: v16.13.0
O.S. : Ubuntu 20.04 Desktop

What am I doing wrongly? How to solve the problem?

Trying to create method that returns a query

So I’m trying to create a method within my User-class, that can return a query from my Azure database. However when im running the method, then I get [Function: getAllUsers] in the terminal, and I’m not really sure why.
I’m not to familiar with methods in generel and I was wondering if any of you could help me. The code can be seen below:

const { Connection, Request } = require("tedious");

// Create connection to database
const config = {
authentication: {
options: {
  userName: "x",
  password: "x" 
},
type: "default"
},
server: "x", 
options: {
database: "x", 
encrypt: true, 
trustServerCertificate: true
}
}

const connection = new Connection(config);

class User {
constructor(user_id = '55', name = 'Don', password = 'dsad', status_id = '3213', 
følger = 'fde') {
    this.user_id = user_id;
    this.name = name;
    this.password = password;
    this.status_id = status_id;
    this.følger = følger;
}
getAllUsers() {
connection.on("connect", err => {
    if (err) {
      console.error(err.message);
    } else {
      queryDatabase();
    }
  });
connection.connect();
console.log("Reading rows from the Table...");

// Read all rows from table
const request = new Request(
  `SELECT * FROM dbo.users`,
  (err, rowCount) => {
    if (err) {
      console.error(err.message);
    } else {
      console.log(`${rowCount} row(s) returned`);
    }
  }
);

request.on("row", columns => {
  columns.forEach(column => {
    console.log("%st%s", column.metadata.colName, column.value);
  });
});

connection.execSql(request);




}
}

const User1 = new User
console.log(User1.getAllUsers)





module.exports = { User }

In Swiper.js, why the carousel scrolls in a different direction when holding the space between slides?

I have a horizontal carousel.

It works fine when holding and swiping the slides, scrolling horizontally.

But when holding and swiping the space between slides, it scrolls vertically instead, which is wrong.

I am wondering how to solve that.

It seems that the spaces between the slides are considered outside the swiper, instead of a part of the swiper.

Here is my config for the swiper HTML element.

  private setSwiperConfig(): void {
    this.swiperConfig = {
      centeredSlides: false,
      spaceBetween: 24,
      slidesPerView: 'auto',
      grabCursor: true,
      allowTouchMove: true,
      shortSwipes: true,
      touchEventsTarget: 'wrapper',
      lazy: true,
      mousewheel: {
        forceToAxis: true
      },
      freeMode: true,
      speed: 500
    };
  }

Please help!

Thanks in advance!