hi guys I kinda need urgent help right now. I have an assignment but currently I have a little challenge with connecting parts. Here is the task
a web app which logs calculations as they happen and shares those calculations with everyone connected to the app.
currently I have implemented a calculator using React and it works perfectly I have also setup a server using node, express and socket.io my current challenge is how to get inputs from the calculator to be displayed in a form of chats which is the socket.io and node setup. Any input is appreciated.
It seems simple enough to put into practice, however I am confused on how the function is being called. Here is the meat of the file.
const asyncUtil = fn =>
function asyncUtilWrap(...args) {
const fnReturn = fn(...args)
const next = args[args.length-1]
return Promise.resolve(fnReturn).catch(next)
}
Here is an example of what its use is
const asyncHandler = require('express-async-handler')
express.get('/', asyncHandler(async (req, res, next) => {
const bar = await foo.findAll();
res.send(bar)
}))
Without express-async-handler
express.get('/',(req, res, next) => {
foo.findAll()
.then ( bar => {
res.send(bar)
} )
.catch(next); // error passed on to the error handling route
})
I don't understand when asyncUtilWrap gets called.
I understand that asyncUtil accepts a function as an argument. In most cases it will be the callback from express. Then in the example we query are databases for all the items. At what point does asuncUtilWrap take over. By the name of it it sounds like it wraps our original function. However I have tried a few console messages within the function and I can't get it to fire off. Any help would be appreciated . Thank you!
asyncUtil
is creating a closure, so the function passed to it will "initialize" the func, returning asyncUtilWrap
with whatever fn
was passed to it; but it'd have to invoked
node_modules
file? If that's the case and you didn't see anything, it might be because you put the log into the unbuilt file rather than the built file; you'd need to find the built file usually in like lib
which will be the transpiled code actually being used from the packag
I got a question please, I have built a react application with MongoDB. In the structure of my project I have 2 folders one is for the Front-end and the other for Backend. In order for me to see the actual result, I run nodemon server.js within the backend folder, and then I run on the project level npm start. My application is working perfectly.
My question to you guys, Would I face any issue if I deploy my project to Netlify ?
hi guys,
i code website using laravel,
i set up mysql is my first database, mongodb is my second database
my .env:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=source
DB_USERNAME=root
DB_PASSWORD=
DB_CONNECTION_SECOND=mongodb
DB_HOST_SECOND=127.0.0.1
DB_PORT_SECOND=27017
DB_DATABASE_SECOND=demo
DB_USERNAME_SECOND=null
DB_PASSWORD_SECOND=null
and i query builder, i get this error:
i have fixed everything i can, please help me
// Check whether the Submit Button is Clicked or not
if(isset($_POST['submit']))
{
//echo "Cliked";
//1. Get the Data From Form
$id=$_POST['id'];
$current_password = md5($_POST['current_password']);
$new_password =md5($_POST['new_password']);
$confirm_password = md5($_POST['confirm_password']);
//2.Check whether the user with current id and password exist or not
$sql = "SELECT * FROM tbl_admin WHERE id=$id AND password='$current_password'";
// Execute the Query
$res = mysqli_query($conn,$sql);
if($res==true)
{
//Check whether data is avilable or not
$count = mysqli_num_rows($res);
if($count==1)
{
//User Exist and Password Can be Changed
//echo "User Found";
//Check whether the new password and confirm match or not
if($new_password==$confirm_password)
{
//Update the Password
//echo "Password Match";
$sql2 = "UPDATE tbl_admin SET passowrd = '$new_password' WHERE id=$id";
//Execute the Query
$res2 = mysqli_query($conn, $sql2);
//Check whether the query executed or not
if($res2==true)
{
//Display Succes Message
//Redirect to MNG Admin Page with Success Message
$_SESSION['change-pwd'] = "<div class='success'>Password Changed Successfully.</div>";
//Redirect the User
header('location:'.SITEURL.'admin/mng-admin.php');
}else{
//Display Erorr Message
//Redirect to MNG Admin Page with Erorr Message
$_SESSION['change-pwd'] = "<div class='error'>Failed to Change Password.</div>";
//Redirect the User
header('location:'.SITEURL.'admin/mng-admin.php');
}
}
else
{
//Redirect to MNG Admin Page with Erorr Message
$_SESSION['pwd-not-match'] = "<div class='error'>Password Did Not Match.</div>";
//Redirect the User
header('location:'.SITEURL.'admin/mng-admin.php');
}
}else{
//User Does not Exist Set Message and Redirect
$_SESSION['user-not-found'] = "<div class='error'>User Not Found.</div>";
//Redirect the User
header('location:'.SITEURL.'admin/mng-admin.php');
}
}
//3. Check whether the New Password and Confirm Password Match or Not
//4. Change Password if all above is true
}
?>
password
let name = "a"
let name = "b"
let name = "b"
^
SyntaxError: Identifier 'name' has already been declared
Hey guys I use cheerio to scrape this table but it return nothing. Did I somehow did wrong ?
<table class="table trackTable">
<thead>
<tr>
<th colspan="4">Consignment No: MY37011088606</th>
</tr>
<tr>
<th>Consignment No</th>
<th>Date & Time</th>
<th>Status</th>
<th>Location</th>
</tr>
</thead>
<tbody>
<tr>
<td>MY37011088606</td>
<td>03/07/2020 14:58:43</td>
<td><b>Delivered</b></td>
<td>Butterworth</td>
</tr>
.....
</table>
and my code was
$ = cheerio.load(response['data']);
$.html();
$('.table#trackTable').each((index, element) => {
if (index === 0) return (true);
console.log(element)
});
Any idea ? is the naming of the selctor wrong?
in the browser i did
$(".table > tbody:nth-child(2)").each(function(i,item) { console.log(item.innerText) });
and it return something , but cheerio doesn't
https://torre.bio/api/bios/
and I usually get this error Access to XMLHttpRequest at 'https://torre.bio/api/bios/john' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
on close investigation at the network tab I found out that any time I hit the above url I am being redirected to https://bio.torre.co/api/bios
. Which seems to show that I may need a proxy server backend to handle access to this url. I have searched and nothing comes close to a solution. A stackoverflow respose "https://stackoverflow.com/questions/70114502/access-to-xmlhttprequest-at-from-origin-http-localhost4200-has-been-bloc " is a close answer but it was implemented with .Net. My app codebase is in react and I need help on setting up a proxy server to consume the API above. Thanks.