Comments (8)
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.
@tommyhpersonalhave you tried:
await this.$http.patch(`/api/tasks/${task.id}`, {
json: { task:"rando info here" }
})
from http.
@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.
Hi @tommyhpersonal
Can you reproduce a simple codesandbox ?
Do you have upgrade to latest http dependency ? What is your previous version ?
from http.
@tommyhpersonal hope you will fix it ;)
you can close your issue and maybe reoponed it if the problem persist with code reproduction :)
from http.
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.
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.
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)
- Sometimes 'Only absolute URLs are supported' error
- How to use parameters? HOT 1
- globals.Headers is not a constructor HOT 4
- Type of onError hook's argument is not correct
- onRequest Hook in asyncData causes nuxt generate to hang forever HOT 1
- Universal fetch
- Unable to get Headers HOT 2
- post method headers
- Support KeepAlive (http agent)
- $get does not return a parsed object but a string HOT 3
- req is not defined ||is this project deprecated ? HOT 1
- Dependency Dashboard
- Ability to import this module in my application?
- Auth header
- link to migration guide is missing
- Authorization header capitalization HOT 1
- how to use responseType: 'blob' in the http configuration
- Issue with Nuxt 3 publicRuntimeConfig?
- Default options are ignored when type is object
- Corrupted links HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from http.