forked from Ovi/DummyJSON
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocs.ejs
143 lines (125 loc) · 3.89 KB
/
docs.ejs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<!DOCTYPE html>
<html lang="en">
<!-- header -->
<%- include('./partials/docs-head') %>
<body>
<!-- header -->
<%- include('./partials/header') %>
<!-- side-nav -->
<%- include('./partials/docs-side-nav') %>
<main>
<div id="hero">
<!-- ads -->
<%- include('./partials/ads', { adId: '9625277182' }) %>
<h1>How to use it</h1>
<p>
DummyJSON can be used with any type of front end project that needs
products, carts, users, todos or any dummy data in JSON format.
</p>
<p>
You can use examples below to check how DummyJSON works.
</p>
<p>
Feel free to enjoy it in your awesome projects!
</p>
</div>
<div class="section">
<h2 id="intro" class="section-intro">
<i class="bx bx-paper-plane"></i>
<a href="#intro" class="no-link">Intro</a>
</h2>
<div class="sub-section">
<h3 id="intro-limit">
<a href="#intro-limit" class="no-link">Limiting Resources</a>
</h3>
<p>
<small>
<i class="bx bx-bulb bx-xs"></i>
All the resources can be used with query params to achieve
pagination and get limited data.
</small>
</p>
<blockquote>
<pre>
<code class="language-js">
fetch('https://dummyjson.com/RESOURCE/?limit=10&skip=5&select=key1,key2,key3');
</code>
</pre>
</blockquote>
<blockquote>
<pre class="result hidden">
<code class="language-json">
</code>
</pre>
</blockquote>
<h3>OR</h3>
<blockquote>
<pre>
<code class="language-js">
fetch('https://dummyjson.com/RESOURCE/?limit=10&skip=5&select=key1&select=key2&select=key3');
</code>
</pre>
</blockquote>
<blockquote>
<pre class="result hidden">
<code class="language-json">
</code>
</pre>
</blockquote>
</div>
<div class="sub-section">
<h3 id="intro-auth">
<a href="#intro-auth" class="no-link">Authorizing Resources</a>
</h3>
<p>
<small>
<i class="bx bx-lock bx-xs"></i>
All resources can be accessed via an authentication token to test
as a logged-in user.
</small>
<br />
<small>
<i class="bx bx-right-arrow bx-xs"></i>
Go to <a href="/docs/auth">auth module</a> and generate an auth
token to get data as an authorized user
</small>
</p>
<blockquote>
<pre>
<code class="language-js">
/* providing token in bearer */
fetch('https://dummyjson.com/auth/RESOURCE', {
method: 'GET', /* or POST/PUT/PATCH/DELETE */
headers: {
'Authorization': 'Bearer /* YOUR_TOKEN_HERE */',
'Content-Type': 'application/json'
},
})
.then(res => res.json())
.then(console.log);
</code>
</pre>
</blockquote>
<blockquote>
<pre class="result hidden">
<code class="language-json">
</code>
</pre>
</blockquote>
</div>
</div>
<div id="next-prev-resource">
<a href="/docs/auth/" class="button">
Auth
<i class="bx bx-right-arrow"></i>
</a>
<a href="/docs/products/" class="button">
Products
<i class="bx bx-right-arrow"></i>
</a>
</div>
<!-- side-nav -->
<%- include('./partials/footer') %>
</main>
</body>
</html>