Skip to content

Instantly share code, notes, and snippets.

Created December 2, 2018 20:17
What would you like to do?
const mongoose = require('mongoose');
module.exports.TakeFromAPI = async (req, res, next) => {
const headers = new Headers();
headers.append('Content-Type', 'application/json');
// Hena el json object elli htb3teh ll API
"<KEY>": '<VALUE>',
"<KEY>": '<VALUE>',
"<KEY>": '<VALUE>',
// Di el result elli htgelk mn el Amazon API
const result = await fetch(<AMAZON_API_URL>, {
body: JSON.stringify(JSON_TO_SEND_TO_API),
method: 'POST',
mode: 'cors',
// Bn7wl el result hena to JSON format 3lshan n3mlha save
const result_json_response = await result.json();
// TRY this line 3lshan tshofi el response howa elli f postman wala la2
// B3d kda el mafrod ykon 3ndk schema shabh el response 3lshan t3mli save f el db
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment