Skip to content

Instantly share code, notes, and snippets.

View bilal-08's full-sized avatar
:electron:
Learning

RedBeeツ bilal-08

:electron:
Learning
View GitHub Profile
function getPreviousdate(date){
const [day,month,year] = date.split('-');
const today = new Date(year,month - 1,day)
const milliseconds = today.getTime() - 86400000
const d2 = new Date(milliseconds);
const Previousdate = d2.toLocaleDateString(['ban', 'id'])
@bilal-08
bilal-08 / postImage.js
Last active December 15, 2022 17:08
How to upload/post image using node-fetch
import FromData from 'form-data'; // form-data depcrecated use alternative, works for now
import fetch from 'node-fetch';
import * as ft from 'file-type'; // for detecting extention of the file from the buffer
const url = 'https://i.waifu.pics/1y5O6HN.jpg'; // example link
const getbuffer = async (url)=> await fetch(url).then(x =>x.buffer());
async function upload(){