Next.js template
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

singleDataRequest.js 340B

123456789101112131415
  1. import apiEndpoints from './apiEndpoints';
  2. export const getSingleData = async (dataId) => {
  3. const response = await fetch(
  4. `http://localhost:3000${apiEndpoints.singleData}${dataId}`
  5. );
  6. const data = await response.json();
  7. if (!response.ok) {
  8. throw new Error(data.message || 'Something went wrong!');
  9. }
  10. return data;
  11. };