Skip to content

Commit 7f93bc5

Browse files
committed
add content-type header
1 parent 5b2d13b commit 7f93bc5

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed

playground/components/header.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import logo from '../assets/logo.svg?url';
77
import type { Tab } from '../../src';
88
import { exportToZip } from '../utils/exportFiles';
99
import { ZoomDropdown } from './zoomDropdown';
10-
import { useAppContext } from '../context';
10+
import { API, useAppContext } from '../context';
1111

1212
export const Header: Component<{
1313
dark: boolean;
@@ -103,12 +103,12 @@ export const Header: Component<{
103103
<Show
104104
when={context.user()?.display}
105105
fallback={
106-
<a href={`https://api.solidjs.com/auth/login?redirect=${window.location.origin}/login?auth=success`}>
106+
<a href={`${API}/auth/login?redirect=${window.location.origin}/login?auth=success`} rel="external">
107107
Login
108108
</a>
109109
}
110110
>
111-
{(x) => x}
111+
{(x) => <a href="/">{x}</a>}
112112
</Show>
113113
</div>
114114
</div>

playground/context.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ interface AppContextType {
88
const AppContext = createContext<AppContextType>();
99

1010
// const API = "http://localhost:8787";
11-
export const API = '/api';
11+
export const API = 'https://api.solidjs.com'; // '/api';
1212

1313
export const AppContextProvider: ParentComponent = (props) => {
1414
const [token, setToken] = createSignal(localStorage.getItem('token') || '');

playground/pages/home.tsx

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,17 @@ interface Repls {
2121
}
2222

2323
export const Home = () => {
24-
const user = useRouteData();
24+
const routeUser = useRouteData();
2525
const context = useAppContext()!;
2626
const navigate = useNavigate();
2727

28-
const [repls] = createResource(
29-
() => user || context.user()?.display,
30-
async (user) => {
31-
if (!user) return { total: 0, list: [] };
32-
const result = await fetch(`${API}/repls/${user}/list`);
33-
return (await result.json()) as Repls;
34-
},
35-
);
28+
const user = () => routeUser || context.user()?.display;
29+
30+
const [repls] = createResource(user, async (user) => {
31+
if (!user) return { total: 0, list: [] };
32+
const result = await fetch(`${API}/repl/${user}/list`);
33+
return (await result.json()) as Repls;
34+
});
3635

3736
return (
3837
<div class="bg-brand-other h-full m-8">
@@ -43,6 +42,7 @@ export const Home = () => {
4342
method: 'POST',
4443
headers: {
4544
authorization: `Bearer ${context.token}`,
45+
'Content-Type': 'application/json',
4646
},
4747
body: JSON.stringify({
4848
title: 'Counter Example',
@@ -71,8 +71,10 @@ export const Home = () => {
7171
<For each={repls()?.list}>
7272
{(repl) => (
7373
<tr>
74-
<td>{repl.title}</td>
75-
<td>{repl.created_at}</td>
74+
<td>
75+
<a href={`${user()}/${repl.id}`}>{repl.title}</a>
76+
</td>
77+
<td>{new Date(repl.created_at).toLocaleString()}</td>
7678
<td>
7779
<Icon path={repl.public ? eye : eyeOff} class="w-6 inline m-2 ml-0" />
7880
<Icon path={x} class="w-6 inline m-2 mr-0 text-red-700" />

0 commit comments

Comments
 (0)