Doubt REST - POST

1

I would like to know if it is possible after the resolution of the promise of a POST if I can get the result and transform into an array

Ex:

axios.post(http://localhost:5000/api/horario/,{
      Nome: nome,
      Horario: horario
    })

I would like to take this data and turn it into an array, is it possible?

    
asked by anonymous 13.09.2017 / 16:16

2 answers

0

Question returned by Sergio:

Do you want to get this data on the server or the client? If it is on the client Axios returns a promise, so you can do .then (res => console.log (res)); This is what you are looking for

    
15.09.2017 / 22:01
0

Promises work with a return of success and error, as well as ajax calls.

In this way, you can execute your promises as follows:

axios
.post(url_da_api, objeto_postado)
.then(function(data) {
   // Código a ser executado no retorno do post, em caso de sucesso
   })
.catch(function(error) {
   // Código a ser executado no retorno do post, em caso de erro
   });

I recommend reading this specification document for promise!     

15.09.2017 / 22:45