Clone and edit this document
Runkit
Runkit
home page
user forum
new notebook
clone notebook
download notebook
support & documentation
log in
sign up
new notebook
help & feedback
clone this notebook
download this notebook
Sign In
Sign Up
RunKit + npm: axios
node v14.20.1
version:
1.0.0
endpoint
share
tweet
var axios = require("axios") var FormData = require('form-data'); // Get a buffer like yours from an online stock image const res = await axios.get('https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png', { responseType: 'arraybuffer'} ) const originalBuffer = Buffer.from(res.data, 'binary') console.log(originalBuffer) // Call the ClipDrop API const form = new FormData() form.append('image_file', originalBuffer, {contentType: "image/jpg", filename: "image.jpg"}) form.append('upscale', 2) const apiResponse = await axios.post('https://apis.clipdrop.co/super-resolution/v1', form, { headers: { 'x-api-key': 'REPLACE_THIS_WITH_YOUR_API_KEY', }, responseType: 'arraybuffer' }) const arrayBuffer = apiResponse.data const buffer = Buffer.from(arrayBuffer, 'binary') console.log(buffer)
Created from: https://npm.runkit.com/axios
Loading…
no comments
sign in
to comment