how to fix error “net::ERR_SSL_SERVER_CERT_BAD_FORMAT” When useing vuejs and nodejs with https and express

前端 未结 2 1791
难免孤独
难免孤独 2021-01-27 07:02

I have some code to send https request in vue.js and when use actions methods in vuex for send https request I get this error in console

GET https://loca

2条回答
  •  旧巷少年郎
    2021-01-27 07:20

    axios performing a GET request, you should send data in url

    axios.get('/user?ID=12345')
      .then(function (response) {
        // handle success
        console.log(response);
      })
      .catch(function (error) {
        // handle error
        console.log(error);
      })
      .finally(function () {
        // always executed
      })
    

    and performing a POST request

    axios.post('/user', {
        firstName: 'Fred',
        lastName: 'Flintstone'
      })
      .then(function (response) {
        console.log(response);
      })
      .catch(function (error) {
        console.log(error);
      });
    

    now in your code you send POST request and this have object to send, you shod use

    Axios.post('https://localhost:443/api/getpeople',{ withCredentials: 
                 true}).then(response=>response.data).then(result=>{
                       commit('setPeople',result);
                   }).catch(error=>{
                 console.log(error.response)
    

    for GET request

    Axios.get('https://localhost:443/api/getpeople').then(response=>response.data).then(result=>{
                       commit('setPeople',result);
                   }).catch(error=>{
                 console.log(error.response)
    

提交回复
热议问题