#Echo not accepting my pointer to a slice of structs

9 messages · Page 1 of 1 (latest)

ionic fern
#

Basically. Long story short. My application is requesting the last 10 posts from my mongodb database.

The route /cache should return all of them however it errors that I've given it a slice to send back as json rather than a pointer to a slice.

This is the project.
https://github.com/xavierhazzardadmin/blog

All I did was build it, run it and then use curl to query it.

I probably haven't explained this well enough but I would appreciate some help with fixing it.

Thanks in advance.

GitHub

Contribute to xavierhazzardadmin/blog development by creating an account on GitHub.

vale sky
#

*[]*models.Post should just be []*models.Post

#

There are very few reasons to use a pointer to a slice, as it is already pointer-ish

ionic fern
#

didn't work either

vale sky
#

What is the exact error?

ionic fern
ionic fern
#

This is the message I get back from the request
{"message":"results argument must be a pointer to a slice, but was a slice"}