NodeJS post_process scripting for user/session example - Error 500


#1

Hi everyone,

I’m trying to append some extra data on user session object after user login, but somehow DF keeps returning 500 error after I call the api.
This is simple code, but I don’t know why it’s breaking.

var url = 'mysql/_table/extra_data/';
if(event.response.status_code === 200) {

    if (platform.session.user && platform.session.user.email){
	    var email = platform.session.user.email;

        platform.api.get(url + email, null, function(body, response) {
            event.response.content.extra_data = {
              JSON.parse(body)
            };
        
            event.response.content_changed = true;
        });
    };
}

Any clues?

Thanks!


#2

Hi,

I think I might have the same issue.
When activating event script on user.session.post.post_process I get this error: “strpos() expects parameter 1 to be string, array given”. (error here)
Did you solved your problem?

Gabriel


#3

Unfortunately not. I’m actually thinking about migrating my back-end services to IBM Loopback, since it seems more robust and professional, and it has a more detailed documentation.
If Dreamfactory team invested in good documentation, which I think is very poor, I’d never think about migrating to another REST API back-end solution and wouldn’t ask simple questions to the community.
Good luck!


#4

You might want to look at console logs for the error it throws up.

Yes, I feel the documentation doesn’t cover many scenarios. Many a times I’ve got stuck too spending long hours in very simple stuff. But DF is a very good platform so far. The learning curve is sharp but definitely better than IBM loopback I feel. Have you used loopback? It would be good to have a comparison chart with pros and cons.