This commit is contained in:
@@ -1,27 +0,0 @@
|
||||
import axios from 'axios'
|
||||
import { defineEventHandler } from 'h3'
|
||||
|
||||
export default defineEventHandler(async () => {
|
||||
const businessId = '216467845'
|
||||
const token = 'ACMA:jSy96waKHy8jbq5NqjlGy77WarNYKOYO8aEgjExw:b9ff0949'
|
||||
|
||||
try {
|
||||
const response = await axios.post(
|
||||
`https://api.partner.market.yandex.ru/v2/businesses/${businessId}/logistics-points`,
|
||||
{},
|
||||
{
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept-Language': 'ru-RU',
|
||||
'Authorization': `Bearer ${token}`,
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
return response.data
|
||||
}
|
||||
catch (error) {
|
||||
console.error('Ошибка при запросе к Яндекс API:', error)
|
||||
return { error: 'Не удалось получить точки ПВЗ' }
|
||||
}
|
||||
})
|
||||
30
server/api/yandex_location.ts
Normal file
30
server/api/yandex_location.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import axios from 'axios'
|
||||
import { defineEventHandler, readBody } from 'h3'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
try {
|
||||
const data = await readBody(event)
|
||||
const apiUrl = process.env.VITE_YANDEX_B2B_BASE_URL!
|
||||
const token = process.env.VITE_YANDEX_B2B_TOKEN!
|
||||
|
||||
const response = await axios.post(
|
||||
`${apiUrl}/location/detect`,
|
||||
{
|
||||
location: data?.location,
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept-Language': 'ru-RU',
|
||||
'Authorization': `Bearer ${token}`,
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
return response.data
|
||||
}
|
||||
catch (error) {
|
||||
console.error('Ошибка при запросе к Яндекс API:', error)
|
||||
return { error: `Не удалось получить координаты: ${error}` }
|
||||
}
|
||||
})
|
||||
31
server/api/yandex_pvz.ts
Normal file
31
server/api/yandex_pvz.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import axios from 'axios'
|
||||
import { defineEventHandler, readBody } from 'h3'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
try {
|
||||
const data = await readBody(event)
|
||||
const apiUrl = process.env.VITE_YANDEX_B2B_BASE_URL!
|
||||
const token = process.env.VITE_YANDEX_B2B_TOKEN!
|
||||
|
||||
const response = await axios.post(
|
||||
`${apiUrl}/pickup-points/list`,
|
||||
{
|
||||
geo_id: data?.geo_id,
|
||||
type: 'pickup_point',
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept-Language': 'ru-RU',
|
||||
'Authorization': `Bearer ${token}`,
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
return response.data
|
||||
}
|
||||
catch (error) {
|
||||
console.error('Ошибка при запросе к Яндекс API:', error)
|
||||
return { error: `Не удалось получить точки ПВЗ: ${error}` }
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user