get data from the axios response
Some checks failed
Build and publish the docker image / build (push) Failing after 28s
Some checks failed
Build and publish the docker image / build (push) Failing after 28s
Signed-off-by: ngn <ngn@ngn.tf>
This commit is contained in:
parent
0f88c28794
commit
2c7fc2958c
@ -65,16 +65,16 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||
}
|
||||
|
||||
// 4. else getting, caching and sending response
|
||||
const { data } = await axiosInstance(mediaUrl, {
|
||||
const mediaRes = await axiosInstance(mediaUrl, {
|
||||
responseType: 'arraybuffer',
|
||||
});
|
||||
|
||||
// saving in redis for 30 minutes
|
||||
await redis.setex(mediaKey(mediaUrl), ttl, Buffer.from(data));
|
||||
await redis.setex(mediaKey(mediaUrl), ttl, Buffer.from(mediaRes.data));
|
||||
|
||||
// sending media
|
||||
res.setHeader('x-cached', 'false');
|
||||
res.send(data);
|
||||
res.send(mediaRes.data);
|
||||
|
||||
// sending token response on any error
|
||||
} catch {
|
||||
|
Loading…
x
Reference in New Issue
Block a user