Doubt REST - POST

Asked

Viewed 99 times

1

I wonder if it is possible after the resolution of the Promise of a POST if I can get the result and turn 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, it is possible?

  • 2

    Do you want to take that data on the server or client? If it is the client Axios returns a file, then you can do .then(res => console.log(res));. That’s what you’re looking for?

  • That’s right. Thank you

  • Okay, you tested then join .then(res => console.log(res)); to question code? worked as you wanted?

2 answers

0


Question returned in the comment by Sergio:

Do you want to take that data on the server or client? If it is on the client Axios returns a file, then you can do it . then(res => console.log(res));. That’s what you’re looking for

0

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

This way, you can run your files 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 of this document of specification for Promise!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.