mirror of
https://github.com/uetchy/namae.git
synced 2025-03-17 12:30:32 +09:00
feat: switch app store region based on lang
This commit is contained in:
parent
5d17a86779
commit
f3c01ac77f
@ -1,19 +1,19 @@
|
|||||||
const { send, sendError, fetch } = require('../util/http')
|
const { send, sendError, fetch } = require('../util/http')
|
||||||
|
|
||||||
module.exports = async (req, res) => {
|
module.exports = async (req, res) => {
|
||||||
const { query } = req.query
|
const { query, country } = req.query
|
||||||
|
|
||||||
if (!query) {
|
if (!query) {
|
||||||
return res.status(400).json({ error: 'no query given' })
|
return res.status(400).json({ error: 'no query given' })
|
||||||
}
|
}
|
||||||
|
|
||||||
const term = encodeURIComponent(query)
|
const term = encodeURIComponent(query)
|
||||||
const country = 'us'
|
// const country = 'us'
|
||||||
const limit = 3
|
const limit = 3
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
`https://itunes.apple.com/search?media=software&entity=software,iPadSoftware,macSoftware,softwareDeveloper&country=${country}&limit=${limit}&term=${term}`,
|
`https://itunes.apple.com/search?media=software&entity=software,iPadSoftware,macSoftware&country=${country}&limit=${limit}&term=${term}`,
|
||||||
'GET'
|
'GET'
|
||||||
)
|
)
|
||||||
const body = await response.json()
|
const body = await response.json()
|
||||||
|
@ -18,5 +18,6 @@
|
|||||||
"s3": "AWS S3",
|
"s3": "AWS S3",
|
||||||
"jsorg": "js.org"
|
"jsorg": "js.org"
|
||||||
},
|
},
|
||||||
|
"countryCode": "us",
|
||||||
"try": "How about"
|
"try": "How about"
|
||||||
}
|
}
|
||||||
|
@ -18,5 +18,6 @@
|
|||||||
"s3": "AWS S3",
|
"s3": "AWS S3",
|
||||||
"jsorg": "js.org"
|
"jsorg": "js.org"
|
||||||
},
|
},
|
||||||
|
"countryCode": "jp",
|
||||||
"try": "これはどう?"
|
"try": "これはどう?"
|
||||||
}
|
}
|
||||||
|
@ -6,8 +6,11 @@ import { FaAppStore } from 'react-icons/fa'
|
|||||||
import { Card, Result } from '../Cards'
|
import { Card, Result } from '../Cards'
|
||||||
|
|
||||||
function Search({ query }) {
|
function Search({ query }) {
|
||||||
|
const { t } = useTranslation()
|
||||||
const term = encodeURIComponent(query)
|
const term = encodeURIComponent(query)
|
||||||
const response = useFetch(`/availability/appstore/${term}`)
|
const response = useFetch(
|
||||||
|
`/availability/appstore/${term}?country=${t('countryCode')}`
|
||||||
|
)
|
||||||
const apps = response.result
|
const apps = response.result
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user