400 Bad Request Error
See original GitHub issueDescribe the issue
I have developed an Discord AI Chatbot, everything worked just fine until now, the bot gives no response due to axios giving an 400 Bad Request error
Example Code
Code snippet to illustrate your question
const chatSend = async (message) => {
try {
let bid = process.env.bid
let key = process.env.key
let uid = "1"
let msg = message.content
message.channel.startTyping()
await axios.get(`http://api.brainshop.ai/get?bid=${bid}&key=${key}&uid=${uid}&msg=${msg}`)
.then(res => {
let data = res.data;
let reply = data.cnt
console.log(reply)
if (reply) {
message.channel.stopTyping();
message.sendInline(reply, { allowedMentions: { repliedUser: false } });
} else if(!reply) {
message.channel.stopTyping();
message.sendInline("api did not respond at time [TIME OUT]", { allowedMentions: { repliedUser: false } });
}
})
} catch (e) {
message.channel.stopTyping();
console.log(e);
}
};
Expected behavior, if applicable
The Bot is supposed to answer to the question with an random answer
Environment
- Axios Version [e.g. 0.18.0]: 0.21.1
- Adapter [e.g. XHR/HTTP]: HTTP
- Browser [e.g. Chrome, Safari]: Opera GX
- Browser Version [e.g. 22]: LVL3 (core: 83.0.4254.70)
- Node.js Version [e.g. 13.0.1]: 16.13.1
- OS: [e.g. iOS 12.1.0, OSX 10.13.4]: Windows 10
- Additional Library Versions [e.g. React 16.7, React Native 0.58.0]
Additional context/Screenshots
Add any other context about the problem here. If applicable, add screenshots to help explain.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:7
Top Results From Across the Web
How to Fix a 400 Bad Request Error (Causes and Fixes)
The 400 (Bad Request) status code indicates that the server cannot or will not process the request due to something that is perceived...
Read more >How to Fix a 400 Bad Request Error: 8 Easy Methods
The 400 bad request error is an HTTP status code that describes an error caused by an invalid request. Thus, the server can't...
Read more >What is a 400 Bad Request Error (and How Can I Fix It)?
A 400 Bad Request Error occurs when a request sent to the website server is incorrect or corrupt, and the server receiving the...
Read more >How to Fix the 400 Bad Request Error
The 400 Bad Request error means that the request you sent to the website server to view the page was somehow incorrect.
Read more >400 Bad Request Error: What It Is and How to Fix It
The 400 Bad Request Error is an HTTP response status code indicating that the server was unable to process the request sent by...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Okay look, this is not a support forum for people learning to code but an issue board for axios
Just do a console.log(
http://api.brainshop.ai/get?bid=${bid}&key=${key}&uid=${uid}&msg=${msg}') and you’ll get the url, paste it in the browser it’ll give you an HTTP error 400 because params are malformed. likely because you need to use encodeURIComponent on them before putting them in the URL or better yet use axios to correctly encode themWhat does this have to do with axios?
Just look at your API and figure out why it’s giving a 400
http://api.brainshop.ai/get
You’re probably missing your environnement variables or are not encoding the parameters