I'm currently attempting to interact with a Gateway and decided to test out the https://www.npmjs.com/package/@types/request module.
Below is the snippet of code I am trying to execute:
export class OAuthAccessor {
//some stuff
public static createOAuthAccessToken() {
this.makeCall(); //this line 11
}
private static makeCall() {
var request = require('request');
request.post({
uri: "https://api.sandbox.paypal.com/v1/oauth2/token",
headers: {
"Accept": "application/json",
"Accept-Language": "en_US",
"content-type": "application/x-www-form-urlencoded"
},
auth: {
'user': this.clientID,
'pass': this.secret,
// 'sendImmediately': false
},
form: {
"grant_type": "client_credentials"
}
}, function(error, response, body) {
console.log("error = " + error);
console.log(body);
});
}
}
Error Message:
file:///.../OAuthAccessor.js:11:30: JS ERROR Error: Could not find module 'request'. Computed path '/Users/admin/Library/Developer/CoreSimulator/Devices/ACA260DA-C0FD-4373-8822-447422199751/data/Containers/Bundle/Application/EE654C43-B629-4817-929F-F4E52DA1A99F/IPGIntegration.app/app/tns_modules/request'
Contents of My Package.json file:
{
"description": "NativeScript Application",
"license": "SEE LICENSE IN <your-license-filename>",
"readme": "NativeScript Application",
"repository": "<fill-your-repository-here>",
"nativescript": {
"id": "org.nativescript.IPGIntegration",
"tns-ios": {
"version": "3.1.0"
},
"tns-android": {
"version": "3.1.1"
}
},
"dependencies": {
"@types/request": "^2.0.0",
"nativescript-theme-core": "~1.0.2",
"require": "^2.4.20",
"tns-core-modules": "~3.1.0"
},
"devDependencies": {
"babel-traverse": "6.25.0",
"babel-types": "6.25.0",
"babylon": "6.17.4",
"lazy": "1.0.11",
"nativescript-dev-typescript": "~0.5.0",
"typescript": "~2.3.4"
}
}
Details in My tsconfig.json file:
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"noEmitHelpers": true,
"noEmitOnError": true,
"lib": [
"es6",
"dom"
],
"baseUrl": ".",
"paths": {
"*": [
"./node_modules/tns-core-modules/*",
"./node_modules/@types/request/*"
]
}
},
"exclude": [
"node_modules",
"platforms",
"**/*.aot.ts"
]
}
Steps taken so far: I initiated a new Project using the typescript template
tns create my-app-name --template typescript
npm install typescript (version 2.3.4)
npm install @types/request
I've attempted re-installing typescript, types/request module, and node_modules folder multiple times, including testing other versions of typescript. Is there something crucial that I might have overlooked during the installation process of that module?