Struggling to return successful API requests with Next.js

Hello there,

I am new to snipcart and I can’t connect to your APi, i work with Next.js and can’t find anything on the forum or the docs releated to my problem. When I make my call with getServerSideProps i get this unhandledRejectionRequest failed with status code 404. It’s seems tthat’s i’m notI am not authorized to connect however i put my secret API key like in the docs.
here my code:

const secret = Buffer.from(process.env.SNIPCART_API_ID).toString('base64');
	const url = '';
	const config = {
		headers: {
			'Content-Type': 'application/json',
			Authorization: `Basic${secret}`,
	axios.get(url, config).then((result) => {

Help is welcome :grinning:

Hi @exalus

Make sure that there is a space between Basic and ${secret}, add : to the end of the API key, and check your URL. Our API is at *app* and not *api*

Let me know if that helps.


Hello @nelitow , thanks for your fast reply.

So now it works, as you mention my errors was in the URL and the missing space also i was using the public API key… :roll_eyes:
Sorry about my stupid question :sweat_smile:

Thanks for your help and for your time.

No worries, we’re here to help :slight_smile:

1 Like