-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from alura-challenges/aula04
Aula 04 Finalizada
- Loading branch information
Showing
3 changed files
with
80 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { SiteClient } from 'datocms-client'; | ||
|
||
export default async function recebedorDeRequests(request, response) { | ||
if(request.method === 'POST') { | ||
const TOKEN = '3a9782340b8b4df0d359bb792b880b'; | ||
const client = new SiteClient(TOKEN); | ||
|
||
// Validar os dados, antes de sair cadastrando | ||
const registroCriado = await client.items.create({ | ||
itemType: "836335", // ID do Model de "Communities" criado pelo Dato | ||
...request.body, | ||
// title: "Comunidade de Teste", | ||
// imageUrl: "https://github.com/omariosouto.png", | ||
// creatorSlug: "omariosouto" | ||
}) | ||
|
||
console.log(registroCriado); | ||
|
||
response.json({ | ||
dados: 'Algum dado qualquer', | ||
registroCriado: registroCriado, | ||
}) | ||
return; | ||
} | ||
|
||
response.status(404).json({ | ||
message: 'Ainda não temos nada no GET, mas no POST tem!' | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c7ebb62
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: