Search query fails with 400 (Bad reqest)
My Search query to IGDB API is failing with status code 400 if the search text contains a back slash \ in it:
I am using below syntax:
const { q } = req.query
let fields = name, collection
apicalypse(requestOptions)
.fields(fields)
.limit(50)
.search(q)
.request('/games')
.then(response => returnResponse(response, req, res))
.catch(err => returnError(err, req, res))
requestOptions are like this:
const apiPath = 'https://api-v3.igdb.com'
const defaultHeaders = {
'Accept': "application/json",
"user-key": apiKey
}
// Apicalypse Request Options
const requestOptions = {
queryMethod: 'body',
method: 'post', // The default is get
baseURL: apiPath,
headers: defaultHeaders,
responseType: 'json',
timeout: 10000
}
q is \ if I send \ from front-end & abc \ xyz in case of abc \ xyz.
