From a890b9cba04526a6cbb077ccdce47e767a0a1f1a Mon Sep 17 00:00:00 2001 From: Kaio Pimentel Date: Sun, 20 Oct 2024 15:43:38 -0300 Subject: [PATCH] desafio concluido --- services/api.js | 16 +++++++++------- utils/mdx-utils.js | 24 +++++++++++++----------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/services/api.js b/services/api.js index eaf5fc8..376da1f 100644 --- a/services/api.js +++ b/services/api.js @@ -1,9 +1,11 @@ import axios from 'axios'; -export const api = axios.create({ - baseURL: 'https://nuareafrukmnjnaakplk.supabase.co/rest/v1', - headers: { - apikey: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im51YXJlYWZydWttbmpuYWFrcGxrIiwicm9sZSI6ImFub24iLCJpYXQiOjE2NjAyMjc0MjEsImV4cCI6MTk3NTgwMzQyMX0.3qUEldVsmcr_yrpf8N1-qBGdHLB1QCy9nB6-nApVQIA", - authorization: "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im51YXJlYWZydWttbmpuYWFrcGxrIiwicm9sZSI6ImFub24iLCJpYXQiOjE2NjAyMjc0MjEsImV4cCI6MTk3NTgwMzQyMX0.3qUEldVsmcr_yrpf8N1-qBGdHLB1QCy9nB6-nApVQIA" - } -}) \ No newline at end of file +export const api = axios.create({ + baseURL: 'https://gozfobpyaqdqixobbohj.supabase.co/rest/v1/', + headers: { + apikey: + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImdvemZvYnB5YXFkcWl4b2Jib2hqIiwicm9sZSI6ImFub24iLCJpYXQiOjE3Mjk0NDI4OTUsImV4cCI6MjA0NTAxODg5NX0.Je_r9wIIKTuPEi7mFtXNF7fYyArHyLmTuyZnD8Uo7o4', + Authorization: + 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImdvemZvYnB5YXFkcWl4b2Jib2hqIiwicm9sZSI6ImFub24iLCJpYXQiOjE3Mjk0NDI4OTUsImV4cCI6MjA0NTAxODg5NX0.Je_r9wIIKTuPEi7mFtXNF7fYyArHyLmTuyZnD8Uo7o4', + }, +}); diff --git a/utils/mdx-utils.js b/utils/mdx-utils.js index d90061f..5687b02 100644 --- a/utils/mdx-utils.js +++ b/utils/mdx-utils.js @@ -1,19 +1,21 @@ -import { api } from '../services/api' +import { api } from '../services/api'; export const getPosts = async () => { - const {data} = await api.get('/posts'); + const { data } = await api.get('/posts'); - if(data){ - return data; - } + if (data) { + return data; + } - return [] -} + return []; +}; export const getPostBySlug = async (id) => { + const { data } = await api.get(`/posts?id=eq.${id}`); - //TODO: BUSCAR UM POST EM ESPECIFICO. - //const {data} = await api.get(`/post?id=eq.${id}`) + if (data) { + return data[0]; + } - return {} -} \ No newline at end of file + return []; +};