The declaration was marked as deprecated here. solve It

if (this.IsloginMode) {
  authObs = this.Authservice.login(email, password);
} else {
  authObs = this.Authservice.signUp(email, password);
}
authObs.subscribe(resData=> {
    console.log(resData);
    this.Isloading = false;
  },
  (errorMeassage) => {
    console.log(errorMeassage);
    this.error = errorMeassage;
    this.Isloading = false;
  }
);
form.reset();

}

The signature ‘(next?: ((value: AuthResponseData) => void) | null | undefined, error?: ((error: any) => void) | null | undefined, complete?: (() => void) | null | undefined): Subscription’ of ‘authObs.subscribe’ is deprecated.

what and element variable are not defined though code is running

how is compiler know that “element” is the referred to the value of array(prices)

prices.forEach(loop);

function loop(element , what ){
    document.write( what+":"+ element + "<br>");
}

how is compiler know “what” is the index of the array(prices)
and “element” is the value of array(prices)

i was expecting an error since the “element ” and “what ” variable are not defined

Unable to receieve the body object from the react frontend to backend(express) api, while it works fine when submit using postman

Below is my frontend code i have to submit a post request from react.

const { name, email, message } = greeting;
const payload = {
name: name,
email: email,
message: message,
};

console.log(payload);

fetch("http://localhost:8080/greetings", {
  method: "POST",
  mode: "cors",
  headers: {
    "Content-Type": "application/json",
    "Access-Control-Allow-Origin": "*",
    // 'Content-Type': 'application/x-www-form-urlencoded',
  },

  body: JSON.stringify(payload),
})
  .then(async function (res) {
    let response = await res.json();
    console.log(response);
  })
  .catch((err) => console.log(err));

Below is my express code for post
`
app.use(cors());
app.use(bodyParser.urlencoded({ extended: false }));

app.post("/greetings", async (req, res) => {
const { name, email, message } = req.body;
console.log(req.body);
db();
const saveDocument = new Document({
name: name,
email: email,
message: message,
});

await saveDocument
.save()
.then((savedDoc) => {
  res.send({ status: 200, mes: "success", request: req.body });
})
.catch((e) => console.log(e));
});

`
I have tried to submit a post using postman and i was able to see data in my mongoDB. But from my frontend i always get an empty object in the request.body.

enter image description here

PHP MySQL Query for jQuery Live Search Box – Unable to Output from Different Columns Based on Input Type

I’m fairly new to PHP/MySQL/jQuery and I’m stuck on this one piece of a large project.

Coding a live seach box that I’d like to return Names or Phone Numbers already in the database based on user input. I can get it to output just Names or just Phone Numbers by changing $variable to “Name” or “Phone”, but I’ve been unable to come up with a working solution to dynamically do either sumultaniouly. I’ve been researching/troubleshooting for hours with if/else using is_numeric() and/or is_nan(), setting a global variable, reworking the query many different ways, and done hours of research. Any suggestions are greatly appreciated!

inventory.php:

<?php
// Session Start
session_start();
// If the user not logged in, redirect to the login page
if (!isset($_SESSION['loggedin'])) {
    header('Location: index.html');
    exit;
}

//Connect to database
require_once('connection.php');


if(isset($_REQUEST["term"])){

    $variable = "Name";            

    // Prepare a select statement
    $sql = "SELECT $variable FROM vendor WHERE $variable LIKE ?";

    if($stmt = mysqli_prepare($conn, $sql)){
        // Bind variables to the prepared statement as parameters
        mysqli_stmt_bind_param($stmt, "s", $param_term);
        
        // Set parameters
        $param_term = $_REQUEST["term"] . '%';
        
        // Attempt to execute the prepared statement
        if(mysqli_stmt_execute($stmt)){
            $vendresult = mysqli_stmt_get_result($stmt);
            
            // Check number of rows in the vendresult set
            if(mysqli_num_rows($vendresult) > 0){
                // Fetch vendresult rows as an associative array
                while($row = mysqli_fetch_array($vendresult, MYSQLI_ASSOC)){
                    echo "<p>" . $row["$variable"] . "</p>";
                }
            } else{
                echo "<p>No Match Found - Vendor Setup</p>";
            }
        } else{
            echo "ERROR: Could not able to execute $sql. " . mysqli_error($conn);
        }
    }

    // Close statement
    mysqli_stmt_close($stmt);
}
 
// close connection
mysqli_close($conn);
?>

HEAD portion of inventoryentry.php:

            <script>
                $(document).ready(function(){
                    $('.search-box input[type="text"]').on("keyup input", function(){
                        /* Get input value on change */
                            var inputVal = $(this).val();
                            var vendresultDropdown = $(this).siblings(".vendresult");
                            if(inputVal.length){
                                $.get("backend-search.php", {term: inputVal}).done(function(data){
                                    // Display the returned data in browser
                                        vendresultDropdown.html(data);
                                });
                            } else{
                                vendresultDropdown.empty();
                            }
                    });
    
                    // Set search input value on click of vendresult item
                    $(document).on("click", ".vendresult p", function(){
                    $(this).parents(".search-box").find('input[type="text"]').val($(this).text());
                    $(this).parent(".vendresult").empty();
                    });
                });
            </script>

BODY portion of inventoryentry.php:

<div class="search-box"><input type="text" autocomplete="off" placeholder="Vendor Lookup" /><div class="vendresult"></div></div>

Code does work, but not in the way I’d like.

JavaScript – Put new data in LocalStorage on input change event

I am trying to develop a todolist with localStorage so when the users come back on the page the data from their lists is well loaded.
I have already the script to save to data and to load it when the page refresh but :

  • This is what I want to do : I would like to refresh the data in the localStorage when a user change the value of an input (current tasks).
    To be honest I don’t really know how I can do that.
<!DOCTYPE html>
<html lang="fr">
    <head>
        <?php include 'layout/head.phtml'; ?>
    </head>

    <body>

    <header>
            <?php include 'layout/header.phtml'; ?>
    </header>

    <main>
        <div class="container">
            <div class="row">
                <div class="col-lg-12">
                    <!--Add list name h3-->
                    <h4>En cours</h4>
                    <div id="tasks-container">
                        
                    </div>
                    <div class="new-task-container-submit">
                        <form id="form-add-task" action="">
                            <input class="btn-style" type="submit" id="new-task-submit" value="+" title="Ajouter">
                            <input class="input-style" type="text" id="new-task-input" placeholder="Ajouter une tâche">
                        </form>
                    </div>
                    <div class="completed-tasks-container">
                        <h4>Terminées</h4>
                    </div>
                </div>
            </div>
        </div>
    </main>
    <footer>
        <?php include 'layout/footer.phtml'; ?>
    </footer>

    <script type="text/javascript" src="scripts/main.js"></script>
    </body>
let inputNewTask = document.querySelector("#new-task-input");
let tasksContainer = document.querySelector("#tasks-container");
let formAddTask = document.querySelector("#form-add-task");

let tasksList = [];
let tasksID = 1;

function genererTasks(){
    const listTasksJson = window.localStorage.getItem("Tasks name");
    const listTasks = JSON.parse(listTasksJson);

    for(let i = 0; i < listTasks.length; i++){
        
        let newTaskContainer = document.createElement("div");
        newTaskContainer.classList.add("new-task-container");
        let newTaskInput = document.createElement("input");
        newTaskInput.classList.add("input-style", "task-content");
        newTaskInput.id = "task-" + tasksID;
        tasksID = tasksID + 1;
        newTaskInput.type = "text";
        newTaskInput.value = listTasks[i];
        newTaskInput.textContent = listTasks[i].value;
        
        let iconDelete = document.createElement("i");
        iconDelete.classList.add("fa-regular", "fa-circle", "btn-style");

        tasksContainer.appendChild(newTaskContainer);
        newTaskContainer.appendChild(iconDelete);
        newTaskContainer.appendChild(newTaskInput);
        
        tasksList.push(listTasks[i]);
    }
}

//Generate the page
const listTasksJson = (localStorage.getItem("Tasks name") !== null);
if (listTasksJson){
    genererTasks();
}

//Listener add new task
formAddTask.addEventListener("submit", function(e){
    e.preventDefault();
    let taskContent = inputNewTask.value;
    if(!taskContent){
        alert("Veuillez remplir le champs");
    }else{
        
        inputNewTask.value = "";
        let newTaskContainer = document.createElement("div");
        newTaskContainer.classList.add("new-task-container");
        let newTaskInput = document.createElement("input");
        newTaskInput.classList.add("input-style" , "task-content");
        newTaskInput.id = "task-" + tasksID;
        tasksID = tasksID + 1;
        newTaskInput.type = "text";
        newTaskInput.value = taskContent;
        newTaskInput.textContent = taskContent.value;
        
        let iconDelete = document.createElement("i");
        iconDelete.classList.add("fa-regular", "fa-circle", "btn-style");

        tasksContainer.appendChild(newTaskContainer);
        newTaskContainer.appendChild(iconDelete);
        newTaskContainer.appendChild(newTaskInput);
        

        tasksList.push(taskContent);
        window.localStorage.setItem("Tasks name", JSON.stringify(tasksList));
    }
})

// Listener to change text tasks and put the new data in LocalStorage



//window.localStorage.removeItem("Tasks name");

I tried with change event but the only thing I am able to do is when I change the value of one input, the entire array is replace with the value of the one (don’t know if i’m clear)
I set id’s on my input element maybe I can use it?

Angular: Error occured while trying to proxy request “/api/v1/application/:id” from localhost:4200 to http://localhost:4000

This is my config.dev.json file:

{
  "/api/v1": {
    "target": "http://localhost:4000",
    "secure": false,
    "logLevel": "debug",
    "changeOrigin": true
  }
}

Error that i am facing:

Angular:
[HPM] Error occurred while trying to proxy request /api/v1/application/1e21006e-3588-4699-a7ce-1847b7c5409d from localhost:4200 to http://localhost:4000 (ECONNREFUSED) (https://nodejs.org/api/errors.html#errors_common_system_errors)

Nest Js:
Error: write EPIPE

Could anyone sugsest some solution

How to iterate two maps in the javascript based on index

I just created two maps in the javascript by using below lines of code.

let myMap = new Map();
let myMap1 = new Map();

I just added the below data in the respective map.

//The below is just for example and the actual is different

myMap1 = new Map([
  ['country', 'Chile'],
  ['age', 30],
]);

myMap = new Map([
  ['country', 'Austria'],
  ['age', 20],
]);

There is a reason to keep the two map here because in the real time I’m trying to get the data from two different schema to store two different data in the Maps.

Now, I’m trying to iterate the both Map in the below order

Iteration-1 : country, Chile, country, Austria. //Index 0 from both the maps

Iteration-2 : age, 30 , age, 20.  // Index 1 from both the maps.

I just want to iterate both the Maps in the single forEach and I want to take both index value and key and pass it for other logical operations.

Can someone assist me to solve this?

I tried the below way to iterate one Map but not sure how to do for two Maps

myMap.forEach (function(value, key) {
                            let array = key.split(":::");
                            htmlSkelton += 
                            "<tr>"+
                            "<th scope='row'>"+(counter++) +"</th>"+
                            "<td>"+array[1]+"</td>"+
                            "<td>"+array[0]+"</td>"+
                            "<td>"+value+"</td>"+
                            "</tr>"
                          })

Image source seems to be correct but I get 404

simple code is written.

<header>
    <div>
        <img src="../../images/bonjour_logo.png" alt="">
    </div>
</header>

I’m just trying to get this image into my header and I’m getting this error: Failed to load resource: the server responded with a status of 404 (Not Found)

I’m pretty sure my path is correct, but maybe I’m wrong.

enter image description here

How to wait for onAuthStateChanged to be executed first?

i have created a separate file for all pages to check that user is logged in or not and get the uid from it,so I created a a file call GetLoginedUser.js

Code :

 import { app, db } from "./FiiireBaseConfig";
import { getAuth, onAuthStateChanged } from "firebase/auth";

const auth = getAuth();

export async function getUser() {
  var uId ="Uid Will be here";
 

  console.log("Get User Started");

  await onAuthStateChanged(auth,  (user) => {
    if (user) {
     
      uId = user.uid;
    } else {
    
      alert("No User Found");
    }
  });

  console.log("get user ended");
  return uId;
}

Now I imported this function into another file
Code :-

 const { getUser } = require("./GetLoginedUser");
    
    var user ;
    async function updateUserImage() {
      user = await getUser();
      console.log("user:" + user);
    }
    updateUserImage();

But the problem is it don’t wait for onAuthStateChanged and returns the initial value. So the output will come like User: Uid will be here not updated!

Dynamic how to execute using nested objects, arrays

Working as expected.
i have using this body of JSON passing to JavaScript its insert into SQL table.
Input

data : 
[{
    "name": "John",
    "detail" : "contact",
    "type" : "phone",
    "value"  : "987-654-3210"
},
{    "name": "John",
    "detail" : "contact",
    "type" : "email",
    "value"  : "[email protected]"
},
{    "name": "John",
    "detail" : "address",
    "type" : "city",
    "value"  : "Berlin"
},
{   "name": "John",
    "detail" : "address",
    "type" : "country",
    "value"  : "Germany"
}]

Javascript Process

var data;
var rawdata =  JSON.parse(JSON.stringify(data));

var query= ""

arrayLength = rawdata.length;

for (var i = 0; i < arrayLength; i++) { 

query +=` begin
          insert into [dbname].[dbo].[table] (name,detail,type,value) 
         values('` + rawdata[i].name+ `','` + rawdata[i].detail + `','` + rawdata[i].type+ `','` + 
             '` + rawdata[i].value + `')
            end       
}
return query;

SQL table Output

| name     | detail   |type     |value           |
| -------- | -------- |---------|----------------|
| John     | contact  |phone    |987-654-3210    |
| John     | contact  |email    |[email protected] |
| John     | address  |city     |Berlin          |
| John     | address  |country  |Germany         |

Below i have this body of JSON.
How to pass to JavaScript function to insert into SQL table?

Input

{
    "data": [{
        "name": "John",
        "contact": {
            "phone": "987-654-3210",
            "email": "[email protected]"
        },
        "address": {
            "city": "Berlin",
            "country": "Germany"
        }
    }]
}

SQL table Output

| name     | detail   |type     |value           |
| -------- | -------- |---------|----------------|
| John     | contact  |phone    |987-654-3210    |
| John     | contact  |email    |[email protected] |
| John     | address  |city     |Berlin          |
| John     | address  |country  |Germany         |

How to create JavaScript function ? Any suggestion on this?

React Leaflet map rendering all over the page

I am fairly new to React and Leaflet. I have gotten Leaflet working just fine in a simple HTML page. So now I am trying to make a more dynamic site by using React.

The problem I am running into is I can get it to render sort-of. The map appears all over the page in chunks. I put an h1 above and a simple div with text below the map dev and you can see it render randomly past the lower text. its also not one contiguous map.

I’m using React v18.2.0 with React Leaflet at 4.2.1 with Leaflet 1.9.3.

Here is my app code:

import React from 'react';
import './App.css';
import { MapContainer, TileLayer, Marker, Popup } from 'react-leaflet';

function App() {
  return (
    <div>
      <h1>See my map</h1>
      <MapContainer center={[45.4, -75.7]} zoom={12}scrollWheelZoom={false}>
        <TileLayer
          url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
          attribution='&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
        />
      </MapContainer>
      <div>After map report</div>
    </div>
  );
}

export default App;

enter image description here
enter image description here

I would love for any advice on what is going on and what I can do to fix it.

Thanks!

Is there a way Bytecode matches with etherscan verification process validating Smart Contract

Trying to validate a Smart Contract but keep getting ByteCode error as Etherscan can’t match the correct one.

In Solidity everything works perfect but unable to validate in Etherscan.

Contract address: 0xa788612af215b661ed064895b34fcb620866c377

Error message:

Compiler debug log:
Error! Unable to generate Contract ByteCode and ABI
Found the following ContractName(s) in source code : Address, Cloudy, Context, ERC1155, ERC1155Supply, ERC165, IERC1155, IERC1155MetadataURI, IERC1155Receiver, IERC165, Math, Ownable, Strings

pragma solidity ^0.8.9;
// SPDX-License-Identifier: MIT

import "@openzeppelin/[email protected]/token/ERC1155/ERC1155.sol";
import "@openzeppelin/[email protected]/access/Ownable.sol";
import "@openzeppelin/[email protected]/token/ERC1155/extensions/ERC1155Supply.sol";
import "@openzeppelin/contracts/utils/Strings.sol";



contract Cloudy is ERC1155, Ownable, ERC1155Supply {

    uint256 constant SleepyPinkDragon = 1;
    uint256 constant ThickCloud = 2;
    uint256 constant BlackHairPelicanCloud = 3;
    uint256 constant Superhuman = 4;
    uint256 constant Rattle = 5;

    mapping (uint256 => string) private _uris;

    constructor() ERC1155("https://arweave.net/sJa3zzrBzb2ejG_96_dzv_Jt9IdTdLNMbquxwa0Q/clo.json")
    {
        
     _mint(msg.sender, SleepyPinkDragon, 22, "");
     _mint(msg.sender, ThickCloud, 5, "");
     _mint(msg.sender, BlackHairPelicanCloud, 5, "");
     _mint(msg.sender, Superhuman, 3, "");
     _mint(msg.sender, Rattle, 3, "");
    }


  function uri(uint256 _tokenId) override public pure returns (string memory) {
        return string(abi.encodePacked("https://arweave.net/sJa3zzrBzb2ejG_96_dzv_Jt9IdTdLNMbquxwa0Q/clo", Strings.toString(_tokenId),".json"));
    }


    function setURI(string memory newuri) external onlyOwner {
        _setURI(newuri);
    }


    function mint(address account, uint256 id, uint256 amount, bytes memory data)
        public
        onlyOwner
    {
        _mint(account, id, amount, data);
    }

    function mintBatch(address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data)
        public
        onlyOwner
    {
        _mintBatch(to, ids, amounts, data);
    }

    // The following functions are overrides required by Solidity.

    function _beforeTokenTransfer(address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data)
        internal
        override(ERC1155, ERC1155Supply)
    {
        super._beforeTokenTransfer(operator, from, to, ids, amounts, data);
    }
}

I used the Solidity flattener and copy and paste everything in the Etherscan Verify and Publish option. Still getting that Bytecode unable to match error.

example: I get a very long binary number

ByteCode (what we are looking for):
60806040523480156200001157600080fd5b506040518060800160405280604881526020016...etc