# Consul-template empty array when calling service by .Name

**URL:** <https://discuss.hashicorp.com/t/consul-template-empty-array-when-calling-service-by-name/10803>\
**Category:** Consul\
**Tags:** consul-template\
**Created:** [June 30, 2020, 12:38pm UTC](https://discuss.hashicorp.com/t/consul-template-empty-array-when-calling-service-by-name/10803 "2020-06-30T12:38:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mike-code](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/mike-code/32/5391_2.png) [@mike-code](https://discuss.hashicorp.com/u/mike-code)\
**Post date:** [June 30, 2020, 12:38pm UTC](https://discuss.hashicorp.com/t/consul-template-empty-array-when-calling-service-by-name/10803/1 "2020-06-30T12:38:41Z")

</div>

I have three healthy services which I can see on consul web UI, one of them being consul itself and the two other being defined in the configuration file like so

```
{
	"services": [
		{
			"name": "foo1.bar.dev",
			"address": "10.133.114.235",
			"port": 8010,
			"check":
			{
				"name": "GET Check",
				"http": "http://10.133.114.235:8010",
				"method": "GET",
				"interval": "5s",
				"timeout": "1s"
			}
		}
	]
}

```

Now in the web UI I can see that each service (consul, foo1.bar.dev and foo2.bar.dev) have 1 instance each (where each instance’s name is the same as the service itself, thus foo1.bar.dev, foo2.bar.dev and consul).

The problem is that when I try to iterate over them using snippet from the Readme file, namely

```
{{ range services }}
svc: {{ .Name }}
{{ range service .Name }}
test: {{ .Name }}
{{ end }}{{ end }}

```

I’ll only see consul. The other two will not appear because `{{ range service.Name }}` will return an empty array.

```
svc: consul
test: consul
svc: foo1.bar.dev
svc: foo2.bar.dev

```

I can’t figure out why a service appears in the **list** of services but then it won’t appear when I try to fetch it via `range service`.

---

<div class="post-metadata">

**Author:** ![Wolfsrudel](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/wolfsrudel/32/28465_2.png) [@Wolfsrudel](https://discuss.hashicorp.com/u/Wolfsrudel)\
**Post date:** [June 30, 2020, 7:20pm UTC](https://discuss.hashicorp.com/t/consul-template-empty-array-when-calling-service-by-name/10803/2 "2020-06-30T19:20:43Z")

</div>

```auto
{{ range service.Name }}

```

or

```auto
{{ range service .Name }}

```

?

You have both in your question/ explanation, but which one isn’t working?
