Hi,
I am currently developing an Image Gen API which uses Canvas and Express.JS. The project and endpoint loads fine and I seemed to have an issue with trying to query and pass the image link/text to generate the image.
Example Link: https://natebot-apibeta.glitch.me/image/approved?url=https://i.imgur.com/7xTdTUK.png
It returns:

app.get('/image/approved', async (req, res) => {
if (!req.body.url) return status(false, 'No URL Provided', res);
let check = await isImage(req.body.url);
if (!check) return status(false, 'Invalid Image Type.', res);
let result = await ApprovedEndpoint(req.body.url);
return status(result[0], result[1], res);
});
Same thing happens to text endpoint. if I change the “url=” to “text=” it will show “No Text Provided”. Perhaps I am using the wrong usage of the API link? Code seems very fine to me.
Project: natebot-apibeta
Thank you
1 Like
Hey @NTMNathan,
I couldn’t find the project natebot-apibeta! Perhaps it is set to private?
I’ll send you an invite link to your DM
Just for clarification, I am using the following module versions:
- “body-parser”: “^1.18.3”,
- “canvas”: “^2.3.1”
- “express”: “^4.16.4”
- “node-superfetch”: “^0.1.9”
- “request”: “^2.88.0”
Using req.query
instead of req.body
should fix your issue!
req.body
is for POST requests.
The link you sent works fine. It could be the way your sending back the data. To add: your response returns a Buffer object which you can use Buffer.toString(“whatevercencoding”) to concert the buffer to a string.
I currently have to go somewhere now but when I get back I can take a look!
1 Like
I’ve found your issue. You seem to be returning a Buffer
object.
However, I have modified the code to return a ReadableStream
which can be written to the response which then shows the PNG/image.
2 Likes
Awesome, thank you for resolving the issue.
1 Like