Executing using sqliteObject and sqlite

Hi guys
Please check in this provider I am calling insert function and in console I am able to check inserted message but not after in message i.e.after execute insert function…

export class UserProvider {
    private db: SQLite;
    private db1: SQLiteObject;
    public constructor() {

        this.db=new SQLite();
            name: 'data.db',
            location: 'default'
        }).then((db1: SQLiteObject) => {
            db1.executeSql('create table if not exists user (name VARCHAR(32),email  VARCHAR(32),number  VARCHAR(32),password  VARCHAR(32))', {})
                .then((data) => {
                }).catch(e => console.log(JSON.stringify(e)));
public insert(name:string, email:string, number:string, password:string) {
        this.db1.executeSql('insert into user(name ,email,number,password) values ("' + name + '","' + email + '","' + number + '","' +password + '")', {});

This is really dangerous code on a couple of fronts. First up, due to lack of using placeholders, we have little bobby tables:

Secondly, never ever ever store cleartext passwords. Anywhere. For any reason. People get sued for doing things like that.


Of course will decrypt them and maintain the hash also this is for testing only how to interact with Ionic

I’m sorry, but that is a garbage excuse. There is absolutely no justification for doing something as negligent as storing cleartext passwords “for testing only”. You have to build security into your application from the beginning. Bolting it on later is asking for trouble. You must also realize that you are posting code on a public forum that other people may emulate. It is your responsibility to refrain from perpetuating such terrible code.

It’s on u what u think but I am a php developer and have made secure projects also so I don’t have to explain u what I am going to do hope u have heard about cypher and all that to decrypt passwords see I am new in Ionic so I am just going step by step so how to decrypt in Ionic that also have to search first so thanks hope u will help me in future also if stuck somewhere

Yes, it is, and I think that nobody should emulate the code in your original post. In fact, I think that pretty strongly.

I’ll have to take your word for the first claim, but given what I’ve seen of your posting history here, I am very skeptical about the second.

Word salad, cannot parse.

I would be more motivated to do so if you would stop posting dangerous code that potentially opens people up to lawsuits.

BTW, your initial question is likely related to a fundamental misconception of asynchronous code:

this.db.executeSql(query).then((rslt) => {
  // in here rslt is valid
// but we can't do anything with it out here

I just want to return data back to calling function and data I am getting but the issue is I am not able to console that result

If you are saying “I want to immediately return the result of an asynchronous call”, you can’t. That’s the entire point of asynchronous programming. The best you can do is to return the future to the calling function, and it is their responsibility to deal with it when it resolves.

2 posts were split to a new topic: Web-error response -> body: "Cannot POST