Posts

Showing posts from January 23, 2019

Img.onerror called randomly - SVG string as source

Image
0 I have a routine that takes a canvas context and an SVG string and renders it onto the canvas, that returns a promise that resolves once done. For whatever reason, it fails in Firefox & Safari(haven't tried in IE), but seems to be the only solution I can get to work all the time in Chrome. I've tried a couple different alternatives: convert it to a blob first, run that blob through createObjectURL, set img src to that, draw image on canvas. This works most of the time over HTTP, but over HTTPS it fails the majority of time, but not all the time. Convert it to a blob, use file reader to read it as a base64 SVG representation, set img src to the base64, draw image on canvas. code: export default (ctx, rawSVG, { width, height }) => new Promise((resolve, reject) => { const im

Firebase Cloud Functions Express app return statement

Image
0 I'm currently building a Firebase Cloud function which uses the Spotify API. Now I know this code works since I've also used it before I created an Express app off of this. But since then I cannot seem to get my cloud function to return anything... I really don't get what I'm doing wrong. const app = express(); app.use(cors({ origin: true })); app.get("/", (req, res) => res.send("No track specified")); app.get("/:track", (req, res) => res.send(getTrack(req.params.track))); function getTrack(track) { // Set up Auth options console.log(track); const spotify_auth_options = { url: "https://accounts.spotify.com/api/token", headers: { Authorization: "Basic " + new Buffer(spotify_client_id +