User & Subscription
This page describes all of the page/campaign methods available within the Limio SDK.

getUser - Retrieving details of the current user

If you need to find out if a user is validated and get some details about that user, including Subscription you can use the getUser method.
Example to display authenticated user's email in a navigation bar:
1
import React from "react"
2
import { getUser } from "@limio/sdk"
3
4
const Navbar = () => {
5
const user = getUser()
6
7
const { email } = user
8
9
return (
10
<nav>
11
<h1>Shop</h1>
12
<ul>
13
<li>
14
<p>Logged in as { email }</p>
15
</li>
16
<li>
17
<button>Log Out</button>
18
</li>
19
</ul>
20
</nav>
21
)
22
}
Copied!
Example to display an authenticated user's Subscriptions and the Status of those Subscriptions, as well as upcoming payments:
1
import React from "react"
2
import { getUser } from "@limio/sdk"
3
4
const Subscriptions = () => {
5
const user = getUser()
6
7
const { subscriptions } = user
8
9
return (
10
<div>
11
<h1>Subscriptions</h1>
12
<ul>
13
{
14
subscriptions.map(({ name, status, schedule }) => (
15
<li>
16
<div>
17
<h2>{ name }</h2>
18
<span>{ status }<span>
19
</div>
20
<div>
21
<ul>
22
{
23
schedule.map(({ data: { date, amount, description } }) => (
24
<li>
25
<h3>{ description }</h3>
26
<div>
27
<p>{ new Date(date).toLocaleDateString() }</p>
28
<p>{ amount }</p>
29
<div>
30
</li>
31
))
32
}
33
</ul>
34
</div>
35
<li>
36
))
37
}
38
<ul>
39
</div>
40
)
41
}
Copied!
Example user:
1
{
2
attributes: {
3
aud: "3kde1g4qurqbdmf7p81n6568m0",
4
auth_time: 1610643100,
5
"cognito:username": "dummy_user",
6
7
email_verified: true,
8
event_id: "743826f5-075c-4c36-8bb2-bf343be46f09",
9
exp: 1611848843,
10
iat: 1611845243,
11
iss: "https://cognito-idp.eu-central-1.amazonaws.com/eu-central-1_AVrsbOxSU",
12
sub: "d183e0ec-8baf-4320-b847-c78fad0b1df8",
13
token_use: "id"
14
},
15
subscriptions: [
16
{
17
name: "Limio Monthly",
18
data: {},
19
status: "active",
20
record_type: "subscription",
21
owner: "id-hfmd3qJIYU8XZZo-5JI2UOkdacXd0JXBYlptgRGcLMM",
22
customer: "cus-VsmB6KhU_PTTTGzgvY51Vk2dy5Hf6dLnIX4NitMaK4I",
23
id: "sub-34cb9ce9a3777a164bb1ad471f20a83b",
24
service: "limio",
25
ref: "order-23b46e1b8f4c23f5ecd7151437afb4b6/a85cbcf1-fcbc-4320-be3f-eaacaaff578f",
26
created: "2022-06-09T12:44:38.771Z",
27
reference: "1KPEEEJ8RNF8",
28
mode: "production"
29
offers: [
30
{
31
name: "Limio Monthly",
32
quantity: 1,
33
price: {
34
summary: {
35
headline: "£20/month"
36
},
37
currency: "GBP",
38
amount: 1
39
},
40
products: [],
41
termEndDate: "2022-09-02T10:25:01.000Z",
42
attributes: {
43
autoRenew__limio: true
44
}
45
}
46
}
47
],
48
schedule: [
49
{
50
data: {
51
date: "2022-06-09T12:44:38.771Z",
52
reference: "a85cbcf1-fcbc-4320-be3f-eaacaaff578f_charge0",
53
description: "Limio Monthly",
54
amount: "20.00",
55
currency: "GBP",
56
type: "payment"
57
},
58
status: "pending",
59
record_type: "schedule",
60
related: "sub-34cb9ce9a3777a164bb1ad471f20a83b",
61
owner: "id-hfmd3qJIYU8XZZo-5JI2UOkdacXd0JXBYlptgRGcLMM",
62
id: "schedule-46f188d94a8b0b1ef39ee1afbbebfb99",
63
service: "limio",
64
created: "2022-06-09T12:44:38.771Z",
65
reference: "26U64DIIKB1G",
66
mode: "production"
67
},
68
{
69
data: {
70
date: "2022-07-09T12:44:38.771Z",
71
reference: "a85cbcf1-fcbc-4320-be3f-eaacaaff578f_charge0",
72
description: "Limio Monthly",
73
amount: "20.00",
74
currency: "GBP",
75
type: "payment"
76
},
77
status: "pending",
78
record_type: "schedule",
79
related: "sub-34cb9ce9a3777a164bb1ad471f20a83b",
80
owner: "id-hfmd3qJIYU8XZZo-5JI2UOkdacXd0JXBYlptgRGcLMM",
81
id: "schedule-f0899162c4c161a0f8c2535dd1526334",
82
service: "limio",
83
created: "2022-06-09T12:44:38.771Z",
84
reference: "7GH68M5H61C0",
85
mode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