Update data fetched by asyncData() in Nuxt Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!What is different between asyncData and methods in nuxt js?Difference between Asyncdata vs FetchNuxtjs async await in a page doesnt work on page refreshPassing Data in asyncData Nuxt.jsHow to access to the vue store in the asyncData function of nuxtHow can I access data in asyncData with NuxtData() VS asyncData() in Nuxt & vueShare code in asyncData and mounted using NuxtHow to make Vuex state update after axios callNuxt - asyncData with multiple requests
What does this say in Elvish?
What does it mean that physics no longer uses mechanical models to describe phenomena?
Draw 4 of the same figure in the same tikzpicture
One-one communication
Dyck paths with extra diagonals from valleys (Laser construction)
What does 丫 mean? 丫是什么意思?
What would you call this weird metallic apparatus that allows you to lift people?
How can I set the aperture on my DSLR when it's attached to a telescope instead of a lens?
How often does castling occur in grandmaster games?
1-probability to calculate two events in a row
Intuitive explanation of the rank-nullity theorem
The Nth Gryphon Number
Putting class ranking in CV, but against dept guidelines
Is it possible for SQL statements to execute concurrently within a single session in SQL Server?
If Windows 7 doesn't support WSL, then what is "Subsystem for UNIX-based Applications"?
An adverb for when you're not exaggerating
Do I really need to have a message in a novel to appeal to readers?
What's the point of the test set?
AppleTVs create a chatty alternate WiFi network
What is the meaning of 'breadth' in breadth first search?
Misunderstanding of Sylow theory
How to run automated tests after each commit?
A term for a woman complaining about things/begging in a cute/childish way
Crossing US/Canada Border for less than 24 hours
Update data fetched by asyncData() in Nuxt
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!What is different between asyncData and methods in nuxt js?Difference between Asyncdata vs FetchNuxtjs async await in a page doesnt work on page refreshPassing Data in asyncData Nuxt.jsHow to access to the vue store in the asyncData function of nuxtHow can I access data in asyncData with NuxtData() VS asyncData() in Nuxt & vueShare code in asyncData and mounted using NuxtHow to make Vuex state update after axios callNuxt - asyncData with multiple requests
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I wonder if there is a way to update the data returned by asyncData()? For a forum app, in the post page, I got the replies data in the following way:
async asyncData()
const data:replies=await axios.get('replies.json')
return replies
And render it in the template:
<div v-for="rep in replies">
<div>rep.likes</div>
<div>rep.content</div>
</div>
I want to implement a replyToPost feature in the post page. However, when a user posts a reply, I don't know how to update the replies data that already fetched by the asyncData() method.
nuxt.js
add a comment |
I wonder if there is a way to update the data returned by asyncData()? For a forum app, in the post page, I got the replies data in the following way:
async asyncData()
const data:replies=await axios.get('replies.json')
return replies
And render it in the template:
<div v-for="rep in replies">
<div>rep.likes</div>
<div>rep.content</div>
</div>
I want to implement a replyToPost feature in the post page. However, when a user posts a reply, I don't know how to update the replies data that already fetched by the asyncData() method.
nuxt.js
add a comment |
I wonder if there is a way to update the data returned by asyncData()? For a forum app, in the post page, I got the replies data in the following way:
async asyncData()
const data:replies=await axios.get('replies.json')
return replies
And render it in the template:
<div v-for="rep in replies">
<div>rep.likes</div>
<div>rep.content</div>
</div>
I want to implement a replyToPost feature in the post page. However, when a user posts a reply, I don't know how to update the replies data that already fetched by the asyncData() method.
nuxt.js
I wonder if there is a way to update the data returned by asyncData()? For a forum app, in the post page, I got the replies data in the following way:
async asyncData()
const data:replies=await axios.get('replies.json')
return replies
And render it in the template:
<div v-for="rep in replies">
<div>rep.likes</div>
<div>rep.content</div>
</div>
I want to implement a replyToPost feature in the post page. However, when a user posts a reply, I don't know how to update the replies data that already fetched by the asyncData() method.
nuxt.js
nuxt.js
asked Mar 8 at 21:48
JackJackJackJack
1079
1079
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Any asyncData item, in your case 'replies' behaves just like a regular data item once it is initialised because Nuxt.js will automatically merge the returned object with the component data.. Therefore you can alter it as you would any other data item. I assume 'replies' is an array so you could just have a method:
newReply(reply)
this.replies.push(reply)
and it will be added to the array.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55071469%2fupdate-data-fetched-by-asyncdata-in-nuxt%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Any asyncData item, in your case 'replies' behaves just like a regular data item once it is initialised because Nuxt.js will automatically merge the returned object with the component data.. Therefore you can alter it as you would any other data item. I assume 'replies' is an array so you could just have a method:
newReply(reply)
this.replies.push(reply)
and it will be added to the array.
add a comment |
Any asyncData item, in your case 'replies' behaves just like a regular data item once it is initialised because Nuxt.js will automatically merge the returned object with the component data.. Therefore you can alter it as you would any other data item. I assume 'replies' is an array so you could just have a method:
newReply(reply)
this.replies.push(reply)
and it will be added to the array.
add a comment |
Any asyncData item, in your case 'replies' behaves just like a regular data item once it is initialised because Nuxt.js will automatically merge the returned object with the component data.. Therefore you can alter it as you would any other data item. I assume 'replies' is an array so you could just have a method:
newReply(reply)
this.replies.push(reply)
and it will be added to the array.
Any asyncData item, in your case 'replies' behaves just like a regular data item once it is initialised because Nuxt.js will automatically merge the returned object with the component data.. Therefore you can alter it as you would any other data item. I assume 'replies' is an array so you could just have a method:
newReply(reply)
this.replies.push(reply)
and it will be added to the array.
answered Mar 8 at 22:55
Andrew1325Andrew1325
697313
697313
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55071469%2fupdate-data-fetched-by-asyncdata-in-nuxt%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown