-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8246b5e
commit 9588695
Showing
4 changed files
with
82 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,18 @@ | ||
import axios from 'axios' | ||
|
||
export async function getShortLink(url: string): Promise<string> { | ||
const data = { | ||
const body = { | ||
domain: import.meta.env.VITE_SHORT_IO_DOMAIN, | ||
originalURL: url, | ||
} | ||
|
||
const response = await fetch('https://api.short.io/links/public', { | ||
method: 'post', | ||
const { data } = await axios.post('https://api.short.io/links/public', body, { | ||
headers: { | ||
accept: 'application/json', | ||
'Content-Type': 'application/json', | ||
authorization: import.meta.env.VITE_SHORT_IO_PUBLIC_KEY, | ||
}, | ||
body: JSON.stringify(data), | ||
}) | ||
|
||
const json = await response.json() | ||
return json['shortURL'] | ||
return data['shortURL'] | ||
} |