How to add DOM element script to head section?

I want to add DOM element to head section of HTML. jQuery does not allow adding DOM element script to the head section and they execute instead, Reference. I want to add script tags and write a...

Node.js throws "btoa is not defined" error

In my node.js application I did an npm install btoa-atob so that I could use the btoa() and atob() functions which are native in client-side javascript but for some reason weren't included in...

How to create File object from Blob?

DataTransferItemList.add allows you to override copy operation in javascript. It, however, only accepts File object. Copy event The code in my copy event: var items = (event.clipboardData ||...

Why were Javascript `atob()` and `btoa()` named like that?

In Javascript, window.atob() method decodes a base64 string and window.btoa() method encodes a string into base64. Then why weren't they named like base64Decode() and base64Encode()? atob() and...

Conversion from Uint8Array to UTF-16 string freezes/crashes browser

I'm getting some sort of encoded data from server, which should be properly decoded and displayed on client as string(UTF-16). By the moment I'm doing something like this: _decodeContent:...

how to assign Croppie returned result to IMG?

I've using Croppie jQuery plugin for crop a image And returns a the cropped image encoded in base64. My Code as below: $uploadCrop.croppie('result', { type: 'canvas', size:...

JavaScript - sync wait for async operation (sleep)

I know it was asked here many times and many times answered this is not a way how it should be done, but once more again :) Is it possible, somehow, to call async function (such as timer / ajax...

Download an image using Axios and convert it to base64

I need to download a .jpg image from a remote server and convert it into a base64 format. I'm using axios as my HTTP client. I've tried issuing a git request to the server and checking the...

Why are atob and btoa not reversible

I'm trying to find a simple way to record and temporarily obfuscate answers to "quiz" questions I'm writing in Markdown. (I'll tell the students the quiz answers during the presentation, so I'm...

Convert image path to blob react native

Problem I am trying to create an app with react native and firebase. One of the features I would like for this app is the ability to upload images. I am having some trouble uploading the images...

Decode strange JavaScript code

I don't know much about decoding and encoding, but I found this on my website (it was hacked and someone took over a page in my site). I analysed the page but can't read this: <script...

How can I import an RSA private key in PEM format for use with WebCrypto?

I'm trying to use WebCrypto to sign a token with RSA-PSS, but I keep getting the error: DataError: Data provided to an operation does not meet requirements at crypto.subtle.importKey. This is my...

PHP base64 decode problems with XML

I have a problem with a token wich represents a full XML file as text. It has been encoded with PHP's base64_encode function. The structure of the xml is as follow: <?xml version="1.0"...

How do I encode HTMLTableSectionElement with Base64 and append decoded value

I am saving some child nodes as Base64. This is to make passing a group of elements (nodes) around easier, ultimately saving the base64 string to a database and hopefully reading this back into...

How to show pdf in browser using byte array of pdf in javascript?

I have a controller which send the response Entity as response to ajax call which is in byte array form of pdf. Now i want to show that in browser but nothing works. i tried every suggentions from...

Decoding Base64 pdf giving broken file

Can someone please explain why decoding Base64 giving a broken pdf? I need to find the way how to decode Base64 and get pdf out. When i use this...

Capture and upload image to server using Ionic 4

I've been trying to capture an image and upload it to the server for days but no luck. I'm using Ionic 4 for my client side, and Java as my backend (I used Jersey to expose my backend to...

Uncaught TypeError: Cannot read property addEventListener of null

Im working on an assignment for my javascript class, and I keep getting the error fetch_page.js:109 Uncaught TypeError: Cannot read property 'addEventListener' of null at addEventListeners...

Why is the OCaml type conversion function named in the form "A_of_B"?

The name like "A_of_B" is a unique naming convention in OCaml, but I want to know why. Is it a result of the different language usage between French and English? Or Xavier Leroy's personal...

jwt is not defined even after i imported it with require()

I have follow problem: In my controller createPost i need to use the library JWT but it seems to be undefined and i dont know why const jwt = require("jsonwebtoken"); const atob =...

How to convert Camera Image to blob in ionic 5?

I want to post multipart form data, for this, we can do like this: let formData = new FormData() formData.append('myfile', 'your blob') this.http.post(url, formData) But I don't know how to...

Could not decode JWT payload from base64

I'm going to decode a JWT token from request header, it looks like...

How to upload base64 encoded pdf directly to s3 with nodejs/aws-sdk?

I'm attempting to upload a base64 encoded pdf to S3 with the following code without having to write the file to the filesystem. const AWS = require('aws-sdk'); exports.putBase64 = async...

How to convert blob url to a byte array using javascript only

I have blob url , i need to get it converted into a byte [] for storing purpose . I initially tried converting it to a base64 using FileReader var xhr = new XMLHttpRequest; ...

How to do base64 encoding/decoding when using CloudFront function?

Amazon CloudFront Function is a new feature introduced by AWS. CloudFront Function can be written using JavaScript only....

Dynamically changing content-type in axios reactjs

So here is my issue. I am using JWT authentication in my project and i have an axiosInstance setup in my react project . I also have an interceptor for axiosInstance which takes care of...

How to use pdfjs-dist in vue cli typescript project?

I'm having issues getting pdfjs-dist working in a vue typescript cli project. As soon as I try to use the pdfjs-dist I get this error As far as I can guess it's an issue with my vue.config.js Or...

Convert a string to base64 in JavaScript. btoa and atob are deprecated

I have been working on some projects in VS Code lately and suddenly started receiving notifications in my code that btoa and atob are now deprecated. I can't find any resource for this besides VS...

React Native Fetch video file by chunk / YouTube Data API chunk(multipart) upload

I made a YouTube API upload app. It works great with small video file sizes but with larger sizes my app crashes. The exception happens when I try to get the video file with Fetch(). Question: Is...

npm install failing with error "error Build failed with error code: 1"

i am running npm install command on my project but getting error Build failed with error code: 1 Part of the log posted below. 0 verbose cli [ 0 verbose cli 'C:\\Program...