mirror of
https://github.com/gurnec/removeddit.git
synced 2026-03-11 08:54:27 +00:00
Fix detection when browser language is not English
This commit is contained in:
parent
2f4c8e0c62
commit
aa08dce7c6
1 changed files with 3 additions and 2 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
import { fetchJson, chunk } from '../../utils'
|
import { fetchJson, chunk } from '../../utils'
|
||||||
|
|
||||||
const baseURL = 'https://api.reddit.com'
|
const baseURL = 'https://api.reddit.com'
|
||||||
|
const requestSettings = {headers: {"Accept-Language": "en"}}
|
||||||
|
|
||||||
const errorHandler = (error, from) => {
|
const errorHandler = (error, from) => {
|
||||||
console.error(from + ': ' + error)
|
console.error(from + ': ' + error)
|
||||||
|
|
@ -9,7 +10,7 @@ const errorHandler = (error, from) => {
|
||||||
|
|
||||||
// Return the post itself
|
// Return the post itself
|
||||||
export const getPost = (subreddit, threadID) => (
|
export const getPost = (subreddit, threadID) => (
|
||||||
fetchJson(`${baseURL}/comments/${threadID}.json?limit=1`)
|
fetchJson(`${baseURL}/comments/${threadID}.json?limit=1`, requestSettings)
|
||||||
.then(thread => thread[0].data.children[0].data)
|
.then(thread => thread[0].data.children[0].data)
|
||||||
.catch(error => errorHandler(error, 'reddit.getPost'))
|
.catch(error => errorHandler(error, 'reddit.getPost'))
|
||||||
)
|
)
|
||||||
|
|
@ -23,7 +24,7 @@ export const getPost = (subreddit, threadID) => (
|
||||||
|
|
||||||
// Helper function that fetches a list of comments
|
// Helper function that fetches a list of comments
|
||||||
const fetchComments = (commentIDs) => (
|
const fetchComments = (commentIDs) => (
|
||||||
fetchJson(`${baseURL}/api/info?id=${commentIDs.map(id => `t1_${id}`).join()}`)
|
fetchJson(`${baseURL}/api/info?id=${commentIDs.map(id => `t1_${id}`).join()}`, requestSettings)
|
||||||
.then(results => results.data.children.map(({data}) => data))
|
.then(results => results.data.children.map(({data}) => data))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue