我如何在我的 React 应用程序上通过 Axios 从 Imgur 的 API 发出 GET 请求
How do i make a GET requests from Imgur's API via Axios on my react app
我什么都试过了,一直报错
main.js?attr=_BODkjRO5QpCpDBDHmq3zW7ER-QQAJ8TUaG_zfoS-_UYoHvVr1lIpJQyTDNBAEyN:2605 GET https://api.imgur.com/3/image?query=cars 400
和
createError.js:16 Uncaught (in promise) Error: Request failed with status code 400
at createError (createError.js:16)
at settle (settle.js:17)
at XMLHttpRequest.handleLoad (xhr.js:62)
虽然它可以与他们的 GET 图库一起使用 URL,所以我不明白 GET 图片 URL 是否已损坏。
我的代码:
const response = await axios.get( 'https://api.imgur.com/3/image' , {
params: {query: text},
headers: {
Authorization: 'Client-ID {MY ACTUAL CLIENT ID}'
}
})
console.log(response);
api 就像
https://api.imgur.com/3/image/{imageID}
而不是
https://api.imgur.com/3/image?query=cars
也许您正在寻找这样的东西? https://api.imgur.com/endpoints/gallery#gallery-search
我什么都试过了,一直报错
main.js?attr=_BODkjRO5QpCpDBDHmq3zW7ER-QQAJ8TUaG_zfoS-_UYoHvVr1lIpJQyTDNBAEyN:2605 GET https://api.imgur.com/3/image?query=cars 400
和
createError.js:16 Uncaught (in promise) Error: Request failed with status code 400
at createError (createError.js:16)
at settle (settle.js:17)
at XMLHttpRequest.handleLoad (xhr.js:62)
虽然它可以与他们的 GET 图库一起使用 URL,所以我不明白 GET 图片 URL 是否已损坏。
我的代码:
const response = await axios.get( 'https://api.imgur.com/3/image' , {
params: {query: text},
headers: {
Authorization: 'Client-ID {MY ACTUAL CLIENT ID}'
}
})
console.log(response);
api 就像
https://api.imgur.com/3/image/{imageID}
而不是
https://api.imgur.com/3/image?query=cars
也许您正在寻找这样的东西? https://api.imgur.com/endpoints/gallery#gallery-search