Skip to content

Instantly share code, notes, and snippets.

@uchitwai
uchitwai / guidToByteArray.md
Created October 24, 2025 10:27 — forked from daboxu/guidToByteArray.md
Convert GUID to byte array in Javascript

It is so painful for me when I found there is no code did such so simple thing on the Internet in a simple way. So I did it.

function guidToBytes(guid) {
    var bytes = [];
    guid.split('-').map((number, index) => {
        var bytesInChar = index < 3 ? number.match(/.{1,2}/g).reverse() :  number.match(/.{1,2}/g);
        bytesInChar.map((byte) => { bytes.push(parseInt(byte, 16));})
    });
    return bytes;

}

import React, { useState, useEffect } from 'react';
import { Line } from 'react-chartjs-2';
import axios from 'axios';
function App() {
const [chartData, setChartData] = useState({});
useEffect(() => {
const fetchData = async () => {
const result = await axios.get('http://localhost:5000/stock/AAPL');