Git Product home page Git Product logo

Comments (8)

tommyhpersonal avatar tommyhpersonal commented on September 7, 2024 1

My previous version was one of the 0.2.x versions. It's definitely something wrong with my code. When I made a new version to test it out, I couldn't reproduce the error.

I guess I'll have to keep debugging, but thanks for the help!

from http.

Atinux avatar Atinux commented on September 7, 2024

@tommyhpersonalhave you tried:

await this.$http.patch(`/api/tasks/${task.id}`, {
  json: { task:"rando info here" }
})

from http.

tommyhpersonal avatar tommyhpersonal commented on September 7, 2024

@Atinux Just tried that. That doesn't seem to work.

Weirdest thing is that it was working a couple months back, but out of nowhere it just stopped working.

from http.

Geminii avatar Geminii commented on September 7, 2024

Hi @tommyhpersonal
Can you reproduce a simple codesandbox ?
Do you have upgrade to latest http dependency ? What is your previous version ?

from http.

Geminii avatar Geminii commented on September 7, 2024

@tommyhpersonal hope you will fix it ;)
you can close your issue and maybe reoponed it if the problem persist with code reproduction :)

from http.

tommyhpersonal avatar tommyhpersonal commented on September 7, 2024

That was a really fast reply thank you @Geminii .

I just figured out what the issue was in my code.

Do you know if I can put a this.$http.patch('apiurl', payload) inside a method?

My code currently looks like

  <input type="button" value="Click me" @click="updateCompleted()">
  methods:{
    updateCompleted: async function(){
      var payload = {completed: 0}
      await this.$http.patch(`http://localhost:3000/api/tasks/4`,payload)
      await this.$http.$get('`http://localhost:3000/api/tasks/4')
    }
  }

if I were to put it in the below code, it would work fine

async(){
      var payload = {completed: 0}
      await this.$http.patch(`http://localhost:3000/api/tasks/4`,payload)
      await this.$http.$get('`http://localhost:3000/api/tasks/4')
} 

from http.

Geminii avatar Geminii commented on September 7, 2024

In view of the PATCH documentation, you can pass a payload in the second argument :)

In you want to use it into asyncData, you probably need this code to do this :

async asyncData({ $http }) {
  const payload = { completed: 0 }
  await this.$http.patch(`http://localhost:3000/api/tasks/4`, payload)
  const task = await $http.$get('http://localhost:3000/api/tasks/4')
  return task.json()
}

But if you need it into methods, your code is exact 👍
Don't hesitate if you need some other help 😀

from http.

tommyhpersonal avatar tommyhpersonal commented on September 7, 2024

Thanks for your help @Geminii !

I took a look at that document. I really need it in the methods part of the instance rather than the asyncData part since it's triggered by a click on the page.

It doesn't seem to pass on the payload. It returns {} when I do a console.log(req.body).

Anyways. I got tired of trying to fix it, so in the mean time i'm going to use the axios module. Hopefully this will be resolved in a future update. (Or maybe i'm just doing something wrong in my code)

My "it works, so it's good enough" solution for anyone else who might need it in the future:

  methods:{
    updateCompleted: async function(){
      var payload = {completed: 0}
      await this.$axios.patch(`http://localhost:3000/api/tasks/4`,payload)
      await this.$http.$get('`http://localhost:3000/api/tasks/4')
    }
  }

from http.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.