Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

208
Views
Vue error : "Error in render: "TypeError: right-hand side of 'in' should be an object, got null""

I've create a little API and i tried to get messages, my function return a vector and i want to list the content of this vector for this i use v-for="item in messages" but i have an error: Error in render: "TypeError: right-hand side of 'in' should be an object, got null", i use vuejs cli

my code :

<template>
  <div>
    <div class="messages">
      <ul id="array-rendering">
        <li :v-for="item in messages">
          {{ item.message.content }}
        </li>
      </ul>
  </div>
</template>

<script>
import {login} from "@/login";
import {Messages} from "@/Messages";
export default {
  name: 'Messages',
  data() {
    return {
      messages: null,
      }
    }
  },
  mounted() {
    login('user', 'pass').then(r=>{
      Messages.getMessages(r)
          .then(r=>{
            this.messages = r
          })
    })
  }
}
</script>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

First of all v-for syntax is incorrect. Use "v-for" instead of ":v-for".

The other problem that, you set initial value of messages as null. The problem is you can not loop in null value. You can set empty array or object as initial value.

data() {
return {
  messages: [] // or {},
  }
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!