top of page

Forum Posts

tpolig01
Feb 04, 2019
In Coding with Velo
I'm querying a data collection and attempting to push the results to a mysql table via npm-mysql. When I try to INSERT the data into the table, I get a promise rejection error. What is strange is that I can successfully insert into the table if I only use one variable for all fields. I don't understand this issue. I am querying a data collection and then attempting to push the results to the getData2 function. $w.onReady(function () { $w("#button1").onClick((event) => { wixData.query("fran_collection") .find() .then((results) => { getData2(results) .then(function () { }) .catch(function (err) { console.log("Promise rejection error: " + err); }) }); }); }); export function getData2(results) { return new Promise(function (resolve, reject) { var mysql = require('mysql'); var connection = mysql.createConnection({ host: '', user: '', password: '', database: '' }); connection.connect(function (err) { for (let x = 0; x < results.length; x++) { let Email = results.items[x].title let Org = results.items[x].newField let Affil = results.items[x].affil let sql = `INSERT INTO members (Email,Org, Affil) VALUES ('${Email}','${Org}','${Affil}')`; connection.query(sql, function (err, result2) { if (result2 === undefined) { reject(new Error("Error result is undefined")); } else { resolve(result2) } }); } connection.end(); }); }); } What is strange is if I make the sql statement let sql = `INSERT INTO members (Email,Org, Affil) VALUES ('${Email}','${Email}','${Email}')`; with every field value set to Email it works...but as soon as I try to change a field to a different variable I get the promise rejection error. Any ideas? This one has me stumped.
0
0
52
tpolig01
Jan 23, 2019
In Coding with Velo
I'm trying to understand where the Contact List on Wix comes from, and if I can export it somehow with code. I've looked in my database collections and see no database that matches up with the "Contact List". Can anyone explain to me a little about the Contact List, what it pulls from and how I can export it. I tried to export it with the GUI as well, but don't see it as a drop down option as explained here - https://support.wix.com/en/article/exporting-your-contacts Thanks!
0
3
153
tpolig01
Jan 23, 2019
In Coding with Velo
node.js MySQL package is inserting multiple values into table when it should only be inserting one. I'm using node.js MySQL package to INSERT values with JavaScript. Every time I run the query, multiple values are inserted into the table, as if the query was ran multiple times. I believe maybe it has to do with asynchronous nature of JavaScript and promises. import { getData} from 'backend/MySQL_DB_Connection'; $w.onReady(function () { getData() .then(function (results) { console.log(results); //$w("#html1").postMessage(results); }) .catch(function (err) { console.log("Promise rejection error: " + err); }) }); export function getData() { return new Promise(function (resolve, reject) { var mysql = require('mysql'); var connection = mysql.createConnection({ host: 'ec2-xxxxxxxxe-1.amazonaws.com', user: 'xxxxx', password: 'xxxxx', database: 'xxxxoli_webform' }); connection.connect(function (err) { var sql = "INSERT INTO webform (Name) VALUES ('test1')"; connection.query(sql, function (err, result1) { if (result1 === undefined) { reject(new Error("Error result is undefined")); } else { resolve(result1) } }); connection.end(); }); });
0
1
1k
tpolig01
Jan 17, 2019
In Coding with Velo
I have an html frame within one of my web pages and it contains a web map similar to this one - https://doc.arcgis.com/en/arcgis-online/reference/what-is-web-map.htm I would like this webmap to take up the entire screen and resize dynamically if users are on different size devices. So far all I've been able to do was expand the html frame as large as I can (outside of the normal window of Wix) but this is not a great solution as if the screen is made smaller, the map goes off screen. Is there anyway to set the size as a percentage rather than pixels? Or are there any other workarounds anyone can think of? Perhaps have it opening in a new window? Thanks
1
3
1k
tpolig01
Jan 07, 2019
In Coding with Velo
Currently I'm connecting to an external DB and querying data. The only way I could get it working was to allow all connections % to connect to the DB. How can I limit the connections to only wix.com? I don't know what URL to use? Thanks
0
4
30
tpolig01
Dec 19, 2018
In Coding with Velo
I'm new to Wix. I'm getting this error when I try to console.log data in an html frame. The data is coming from a backend Web Module. Here is the function on the front end export function button1_mouseIn(event) { get_info(function(result){ console.log(result); }); } and this is the code on the backend. Note that this code works when I run locally on just Node.js but when I try to run on Wix environment I get the error. export function get_info(callback) { var mysql = require('mysql'); var connection = mysql.createConnection({ host: 'xxxx', user: 'bob', password: 'xxxxxxx', database: 'xxxxx }); connection.connect(function (err) { if (err) throw err; connection.query("SELECT Name FROM webform", function (err, result) { if (err) throw err; return callback(result); }); connection.end(); }); } Any suggestions are appreciated!
0
0
149
tpolig01
Dec 19, 2018
In Coding with Velo
I'm new to Wix! Please forgive my ignorance. I'm trying to retrieve data from an external MySQL DB. I first approached the task by creating a back end "web module" on Wix using Node.js. I was able to install the node MySQL package and successfully connect to the external DB. However, I've since been advised that this is not the smartest or safest way to go about doing this since credentials are exposed on the client side. Does anyone have suggestions for how this can be achieved? I just want to make sure my efforts are being spent pursuing the correct approach. I've heard mention of creating an API on my DB and consuming on Wix via HTTP requests? This is new to me and I would have to research this but if it the preferred method then I will certainly look into. Thanks
0
10
2k
tpolig01
Dec 17, 2018
In Coding with Velo
Hi - I am new to Wix and I'm trying to connect to an external mysql DB. I've seen people say that it was not possible in the past but I've read of people using NPM mysql. I'm wondering what is the best/easiest way to do this in late 2018. I tried to get the sample code from here https://www.npmjs.com/package/mysql working on a backend web module but get the error 'require' is not defined. Any advice is appreciated! Thanks
0
13
1k

tpolig01

More actions
bottom of page