1. Install buffer npm install buffer
  2. Api-client.js
import axios from "axios";
import { Buffer } from "buffer"; 

const consumerKey = 'consumer key';
const consumerSecret = 'consumer secret';

const encodedCredentials = Buffer.from(`${consumerKey}:${consumerSecret}`).toString('base64');

const clientOrders = axios.create({
    baseURL: 'https://example.com/wp-json',
    headers: {
        'Authorization': `Basic ${encodedCredentials}`
    }
});


export { clientOrders};

By toihid