Skip to content

json: cannot unmarshal array into Go value of type medium.Publications #19

Open
@deepakjois

Description

Executing the code below (access code deleted),

package main

import (
	"fmt"
	"log"

	medium "github.com/medium/medium-sdk-go"
)

func main() {
	m2 := medium.NewClientWithAccessToken("")

	user, err := m2.GetUser("")
	fmt.Printf("User is %q\n", user)
	pubs, err := m2.GetUserPublications(user.ID)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("No. of publications: %d\n", len(pubs.Data))
}

leads to:

User is &{"1278b5260445c10f4e13b9f37f4f60e9e59376cbd8e5230bf1efd5f700160f860" "debugjois" "ದೀಪಕ್/दीपक/دیپک/Deepak" "https://medium.com/@debugjois" "https://cdn-images-1.medium.com/fit/c/400/400/1*VY6glnPvt0Zbgi-uplEV0g.jpeg"}
2018/02/07 16:25:19 json: cannot unmarshal array into Go value of type medium.Publications
exit status 1

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions