What do you want to save?
Add Code snippet
New code examples
-
Javascript 2022-01-23 06:30:57
node fetch response body
const fetch = require('node-fetch'); //npm install node-fetch fetch('https://httpbin.org/post', { method: 'POST', body: 'a=1' }) .then(res => res.json()) .then(json => { // Do something... }) .catch(err => console.log(err)); Add solution -
Javascript 2022-01-22 13:26:56
nextjs Access-Control-Allow-Origin
//npm i cors //# or //yarn add cors import Cors from 'cors' // Initializing the cors middleware const cors = Cors({ methods: ['GET', 'HEAD'], }) // Helper method to wait for a middleware to execute before continuing // And to throw an error when an ... Add solution -
Javascript 2022-01-22 12:15:02
mern stack delete
//MERN STACK DELETE //Route import { deletePost } from "../controllers/posts.js" router.delete("./:id", deletePost) //Controller export const deletePost = async (req, res) => { const { id } = req.params; if (!mongoose.Types.O... Add solution -
Other 2021-12-23 18:36:02
how to send a post by console chrome
fetch('https://www.hackthebox.eu/api/invite/generate', { method: 'POST', body: JSON.stringify({ title: 'foo', body: 'bar', userId: 1 }), headers: { 'Content-type': 'application/json; charset=UTF-8' } }) .then(res => res.json()... Add solution -
Javascript 2021-11-17 19:14:11
how to connect to mongoose and create a model
const express = require('express'); const app = express(); const mongoose = require('mongoose'); const bodyParser = require('body-parser'); app.use(bodyParser.json()); const PORT = process.env.PORT || 3000; //connecting to db try { mongoose.conne... Add solution -
Other 2021-11-17 13:03:14
ionic post The Content-Type header is: application/x-www-form-urlencoded
doLogin() { let url = "http:////Registration"; var headers = new Headers() headers.append('Content-Type', 'application/x-www-form-urlencoded'); let options = new RequestOptions({ headers: headers }); let body= JSON.stringify({ o... Add solution -
Javascript 2021-11-16 21:07:11
get data from api in javascript
<script> function getFromAPI(url, callback){ var obj; fetch(url) .then(res => res.json()) .then(data => obj = data) .then(() => callback(obj)) } getFromAPI('https://jsonplaceholder.typicode.com/posts', getData); function ... Add solution -
BASIC 2021-11-16 10:26:17
CONCEITO DO JWT
apiRoutes.post('/', function (req, res) { if (req.body.UserName != "tadriano" || req.body.PassWord != "102030") { res.json({ success: false, message: 'Usuário ou senha incorreto(s)!' }); } else { let usuario = new user() { n... Add solution