Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'NoneType' object has no attribute 'split' in masonite response.json() #413

Closed
jpmateo022 opened this issue Feb 1, 2021 · 5 comments

Comments

@jpmateo022
Copy link

Hi,

Related to this issue.
MasoniteFramework/orm#346

My scenario in this is in my controller im using response.json and the in the frontend Im doing long pooiling every 5000 seconds.

When I use this kind of response.

            return response.json({
                'code': 200,
                'message': 'SUCCESS',
                'data': True
            },200)

Im getting the error, but when I changed it to

            return {
                'code': 200,
                'message': 'SUCCESS',
                'data': True
            }

Im not getting anymore the error.

@jpmateo022
Copy link
Author

I'll try a different environment to see if I will still encounter the issue.

@girardinsamuel
Copy link
Contributor

girardinsamuel commented Feb 1, 2021

According to https://docs.masoniteproject.com/advanced/responses#json-responses

return response.json({
                'code': 200,
                'message': 'SUCCESS',
                'data': True
            })

is the same as doing

 return {
                'code': 200,
                'message': 'SUCCESS',
                'data': True
            }

But about setting the response status code, it's documented you can do
https://docs.masoniteproject.com/advanced/responses#setting-status-codes

return "string", 200

But I am not sure that it's working when returning a dict.
Finally when returning response.json(), the signature is response.json(payload, status=200), so the default is already 200,
but it should work with an other status code.

@girardinsamuel
Copy link
Contributor

girardinsamuel commented Feb 1, 2021

I was not able to reproduce the issue either...
Your return this response from which method ? (POST, GET, ...) ?

Is it working in you web browser ? in Postman ?

@jpmateo022
Copy link
Author

The request is being done via Ajax request. I'm suspecting now it's my database connection. I'm just currently finishing the development in my local then I'll test it in the test environment.

@jpmateo022
Copy link
Author

I found out now the problem and it's not Masonite. I tried removing threads in my gunicorn and I don't receive the errors anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants