Skip to content
This repository has been archived by the owner on Mar 12, 2024. It is now read-only.

TEST #446

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open

TEST #446

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions fetchDataWithToken.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

To use the provided JWT token in a TypeScript code, you can create a simple example where this token is sent as a part of an HTTP request to a server or used to authenticate a user. Let's create a hypothetical scenario where this token is used to make an authenticated request to a server.

First, you need to install a package to handle HTTP requests. For this example, I'll use axios, a popular HTTP client. You can install it using npm or yarn:

bash
Copy code
npm install axios
Now, here's a simple TypeScript script that uses the JWT token to make an authenticated GET request to a server:

typescript
Copy code
import axios from 'axios';

const jwtToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c';

async function fetchDataWithJWT() {
try {
const response = await axios.get('https://your-api-endpoint.com/data', {
headers: {
Authorization: `Bearer ${jwtToken}`
}
});

console.log('Data:', response.data);
} catch (error) {
console.error('Error fetching data:', error);
}
}

fetchDataWithJWT();