On Wednesday, July 17, 2019 at 7:36:40 AM UTC-7, Tito Garrido wrote:
>
> Hi!
>
> I am trying to call a POST method from a Vue.js frontend. My backend is
> web2py serving a REST API:
> [...]
>
This is the Data sent:
>
>> {'parent_transaction': None, 'transaction_date': '01/01/2019',
>> 'transaction_label': 'label', 'transaction_type': 'Receita', 'treatment':
>> 1, 'transaction_value': 250, 'paid': False, 'payment_method': None}
>>
>
> This is the response:
>
>
>> 1. config: {url: "
>> http://127.0.0.1:8000/controle7030/product/save_transaction", method:
>> "post", data:
>>
>> "{"total_value":250,"costs":[[{"id":1,"product":1,"…85","total_cost":66,"transaction_type":"Receita"}"
>> , headers: {…}, transformRequest: Array(1), …}
>> 2. data: "iderrors"
>> 3. headers: {pragma: "no-cache", content-type: "text/html;
>> charset=utf-8", cache-control: "no-store, no-cache, must-revalidate,
>> post-check=0, pre-check=0", expires: "Wed, 17 Jul 2019 14:35:41 GMT"}
>> 4. request: XMLHttpRequest {onreadystatechange: ƒ, readyState: 4,
>> timeout: 0, withCredentials: false, upload: XMLHttpRequestUpload, …}
>> 5. status: 200
>> 6. statusText: "OK"
>> 7. __proto__: Object
>>
>>
> Any idea what is wrong? What does mean "iderrors"?
>
Does that transaction get entered into the database?
The one thought I have about "iderrors" is that you have a mishmash
occurring in converting the result into JSON.
I'd expect the body of the response to look something like
{"id": 2345, "errors": None}
where 2345 is the value returned by validate_and_insert() [the id field of
the new row in the table] and None to indicate no errors.
/dps
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/web2py/daa835f7-e232-494c-9bbc-def2a249869f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.