top of page
Forum Posts
Rideau Speedeaus
Feb 04, 2023
In Coding with Velo
Hi So I have a simple wixData.get to check if a member id exists in a collection. When I run this in the backend console it gives me the desired null return if the member does not exist however when the site is live it stops the code and just returns an error. The documentation says that it should just return a null if it is not found which is what I want. export function getMember(member) {
let options = {
"suppressAuth": true,
"suppressHooks": true
};
return wixData.get("members",member,options).then((memberData) => { return memberData}).catch(() => {return null})
} The logs from the live site returns the error and the rest of the code does not run. It needs the null. Item [d2f38662c0f08a0ed434852ea8f72def] does not exist in collection [members]. Why the difference and can I just get the null?
0
1
15
Rideau Speedeaus
Jan 01, 2023
In Coding with Velo
Hi I am trying to get a buffer of a pdf file contained in the media manager. I think I am finding that the wix fetch api does not support pdf files? Is there another way to do this?
0
5
89
Rideau Speedeaus
Nov 18, 2022
In Coding with Velo
I've set up a router on my site which is designed to recieve a query. I've used the router query to get the data from a database via Wix data and added it to the ok() function, which also has which router page the user is directed to. I had expected the end user to see the url of the router page and not the url of just the router prefix and the query (which is the link they would have originally clicked on). Is there anyway to force the url displayed in the address bar to show the router page url rather than showing the original query ? Thanks
0
0
7
Rideau Speedeaus
Oct 22, 2021
In Coding with Velo
I am wanting to hide or show buttons and text depending on an input and would like to filter the buttons to hide them or show them. I am not sure if this is possible or I am making a simple error with the notation: export function TitleClick(title) {
let button = "#"+title+"Ascend"
console.log(button)
let sortButtons = $w("#mTypeAscend, #mTypeDescend, #waiversDescend, #waiversAscend, #dateJoinedAscend, #dateJoinedDescend, #nameAscend, #nameDescend, #lastNameAscend, #lastNameDescend")
let hideButtons = sortButtons.filter(item => item != '"$w('+button+')"');
console.log(hideButtons)
hideButtons.forEach(element => {
element.hide()
});
$w("#"+title+"Ascend").show()
} I have attempted several different ways and the hideButtons array always includes the filtered item. Thanks
0
1
21
Rideau Speedeaus
Nov 16, 2020
In Coding with Velo
Why does the code advance here without waiting for the file to upload? function uploadFiles(i) {
if ($w("#uploadButton" + i).value.length > 0) { // visitor chose a file
console.log("Uploading" + i + ": " + $w("#uploadButton" + i).value[0].name + "- Please wait.")
$w("#uploadButton" + i).startUpload()
.then((res) => {
//files.push(res.url);
console.log("Uploaded: " + res);
$w('#uploadButton' + i).buttonLabel = "Uploaded"
return res
})
.catch((uploadError) => {
console.log("File upload error: " + uploadError.errorCode);
console.log(uploadError.errorDescription);
});
} else { // site visitor clicked button but didn't choose a file
console.log("Please choose a file to upload.")
}
}
async function datacollect() {
let toInsert = {
"name": $w('#firstNameTxt').value,
"lastName": $w('#lastNameTxt').value,
"email": $w('#emailTxt').value,
"address": $w('#addressentry').value,
"phone": $w('#phoneNumber').value,
"street": $w('#street').value,
"unit": $w('#unit').value,
"city": $w('#city').value,
"province": $w('#subdivision').value,
"postcode": $w('#postcode').value,
"country": $w('#country').value,
"membershipType": $w('#membershipOption').value,
"language": language,
"gender": $w('#gender').value,
"waiver1": await uploadFiles(1),
"waiver2": await uploadFiles(2),
"waiver3": await uploadFiles(3),
"waiver4": await uploadFiles(4),
"dateOfBirth": $w('#dob').value,
"ltsDescription": $w('#ltsText').value,
"discount": $w('#discount').value,
"bursary": $w('#bursary').value,
"volunteer": $w('#helpTags').value,
"photos": $w('#photoCheckbox').value
}
//return wixData.insert("Registration", toInsert)
return toInsert
}
export function btnSubmit_click(event) {
if ($w('#firstNameTxt').valid && $w('#lastNameTxt').valid && $w('#emailTxt').valid && $w('#phoneNumber').valid && $w('#membershipOption').valid && $w('#city').valid) {
datacollect().then((toInsert) => {
console.log("Inserting: " + toInsert);
wixData.insert("Registration", toInsert).then((res) => {
let item = res;
console.log("uploaded to database", res._id);
})
.catch((err) => {
let errorMsg = err;
console.log("your upload failed");
});
});
}
} This is the result: The uploads only complete after the toInsert is called
0
2
52
Rideau Speedeaus
Nov 11, 2020
In Coding with Velo
I have the following code. I want all four files to finish uploading before it completes the insert to the database, however even though I have used await the data insert attempts to complete while the files are still uploading and creates an error. What am I missing? The file uploads and data insert should be triggered by the submit button click. The files upload okay just doesn't happen till after the data attempts to insert. export function uploadwaivers() {
let files = []
for (let i = 1; i <= 4; i++) {
let x = "#uploadButton" + i;
if ($w(x).value.length > 0) { // visitor chose a file
console.log("Uploading" + i + ": " + $w(x).value[0].name + "- Please wait.")
$w("#uploadButton" + i).startUpload()
.then((res) => {
files.push(res.url);
console.log("Uploaded: " + files);
$w('#uploadButton' + i).buttonLabel = "Uploaded"
return files
})
.catch((uploadError) => {
console.log("File upload error: " + uploadError.errorCode);
console.log(uploadError.errorDescription);
});
} else { // site visitor clicked button but didn't choose a file
console.log("Waiver count: " + files.length + ". Please choose a file to upload.")
}
}
return files
}
async function datacollect() {
const waivers = await uploadwaivers();
let toInsert = {
"name": $w('#firstNameTxt').value,
"lastName": $w('#lastNameTxt').value,
"email": $w('#emailTxt').value,
"address": $w('#addressentry').value,
"phone": $w('#phoneNumber').value,
"street": $w('#street').value,
"unit": $w('#unit').value,
"city": $w('#city').value,
"province": $w('#subdivision').value,
"postcode": $w('#postcode').value,
"country": $w('#country').value,
"membershipType": $w('#membershipOption').value,
"language": language,
"gender": $w('#gender').value,
"waiver1": waivers[0],
"waiver2": waivers[1],
"waiver3": waivers[2],
"waiver4": waivers[3],
"dateOfBirth": $w('#dob').value,
"ltsDescription": $w('#ltsText').value,
"discount": $w('#discount').value,
"bursary": $w('#bursary').value,
"volunteer": $w('#helpTags').value,
"photos": $w('#photoCheckbox').value
}
return wixData.insert("Registration", toInsert)
}
export function btnSubmit_click(event) {
if ($w('#firstNameTxt').valid && $w('#lastNameTxt').valid && $w('#emailTxt').valid && $w('#phoneNumber').valid && $w('#membershipOption').valid && $w('#city').valid) {
datacollect().then((res) => {
let item = res;
console.log("uploaded to database", res._id);
})
.catch((err) => {
let errorMsg = err;
console.log("your upload failed");
});
}
}
0
4
80
Rideau Speedeaus
More actions
bottom of page