Request failed with status code 400

const projectId = 'xx';
const projectSecret = 'xx';
const auth = `Basic ${Buffer.from(`${projectId}:${projectSecret}`).toString('base64')}`;
const client = create({
    host: 'ipfs.infura.io',
    port: 5001,
    protocol: 'https',
    apiPath: '/api/v0',
    headers: {
        authorization: auth,
    },
});

this is the createItem function

async function createItem() {
        const {name, description, price} = formInput
        if (!name || !description || !price || !fileUrl) return
        const data = JSON.stringify({
            name, description, image: fileUrl
        })

        try {
            const added = await client.add(data)
            const url = `https://ipfs.infura.io/ipfs/${added.path}`
            createSale(url)
        } catch (error) {
            console.log('Error uploading file: ', error);
        }
    }

i am getting and error of request failed status code 400

Hi @yugsolanki15,
quote=“yugsolanki15, post:1, topic:6097”]
Basic ${Buffer.from
[/quote]

I think you have a problem here - nested backticks. You may need to look at your quoting, or use concatination, something like:

Buffer.from(USERNAME + ':' + PASSWORD, 'utf8').toString('base64')

Warm regards,
Chris | Infura | ConsenSys