D
D
danilr2019-03-05 18:30:24
JavaScript
danilr, 2019-03-05 18:30:24

Why do I get an empty object from a request as a public API?

I'm writing a request to the public API - https://frontend-test-case.azurewebsites.net/swagg...
and I get an empty object, I don't understand why, maybe I'm passing the parameters incorrectly, please tell me.
Here is the request itself in vuex:

mutations: {
    getData(state, list){
      state.list = list
      console.log(state.list)
    }

  },
  actions:{
    list(context) {
      if (context.search != '') {
        HTTP.post(Routes.getList, {
          params: {
              "period": 0,
              "date": "2019-03-05T15:12:13.319Z"
            }
          })
          .then(data => {
            context.commit('getData', data)
          })
          .catch(error => {
            console.log(error);
          });
      }
    },
  }
})

The route itself:
import axios from 'axios'

export const HTTP = axios.create({
    baseURL: 'https://frontend-test-case.azurewebsites.net',
    timeout: 10000
})

export const Routes = {
    getList: '/api/report/card',
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex, 2019-03-05
@danilr

Your request is invalid
Send data in the body of the request, not in the URL

HTTP.post(Routes.getList, {
          data: {
              "period": 0,
              "date": "2019-03-05T15:12:13.319Z"
            }
          })

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question